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