設置mysql允許遠程訪問
1.登陸mysql數據庫,修改表。
use mysql;
update user set host='%' where user='root';
select host,user from user;
flush privileges;
注意:最后一句很重要,目的是使修改生效,如果沒有寫,則還是不能進行遠程連接。
2.授權用戶,允許從任何主機連接到mysql數據庫。
grant all privileges on *.* to 'root'@'%' identified by 'pwd' with grant option;
flush privileges;
如果只是允許用戶從ip為192.168.1.104的主機連接到mysql服務器。
grant all privileges on *.* to 'root'@'%192.168.1.104' identified by 'Fmty_888_!@#' with grant option;
flush privileges;