1 mysql -u root -pvmwaremysql>use mysql;
局域网段(特定IP):html
1 mysql>update user set host = '192.168.0.49' where user = 'root';
全网访问:mysql
1 mysql>update user set host = '%' where user = 'root';
局域网段(特定IP):sql
1 mysql>insert into user (host,user,password) values('192.168.0.50','root',password('123'));
全网访问:数据库
1 mysql>insert into user (host,user,password) values('%','root',password('123'));
格式以下:服务器
1 GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
范例:ide
局域网段(特定IP):spa
1 grant all privileges on *.* to 'root'@'192.168.0.51'identified by '123' with grant option;
全网访问:code
1 grant all privileges on *.* to 'root'@'%' identified by '123' with grant option;
备注:by后面的' '里的密码能够与服务器端的密码不通,如root在服务器端是123456而by后面的密码能够是123。客户端远程访问用密码123,服务器登陆仍然用123456。htm
1 mysql>FLUSH PRIVILEGES
来自 <http://www.javashuo.com/article/p-nsoqoriw-br.html> blog