如何設置mysql允許外部連接訪問
1.設置mysql允許外部連接訪問(授權):
grant all privileges on *.* to root@'%' identified by '123456' with grant option; flush privileges;
例子:
查詢mysql用戶權限、授權、刷新使生效
select host, user from user; grant all privileges on *.* to root@'%' identified by '密碼' with grant option; flush privileges;
指定ip地址授權:ip地址指的是連接時失敗報錯1130彈出的地址
grant all privileges on *.* to root@'ip地址' identified by '密碼' with grant option; flush privileges;
沒有權限:

連接成功:

注:不管使用navicat還是命令窗口,都是去操作mysql庫中的user
1,可以使用navicat工具進入到數據庫中mysql庫執(zhí)行語句;

2,使用命令執(zhí)行,進入到命令窗口,登錄到mysql服務器進入到mysql庫(use mysql)中,執(zhí)行以上授權語句即可。
連接服務器:
mysql -u root -p

進入mysql數據庫:
use mysql;

查看user表中的數據:
select Host, User,Password from user;

第一種:修改user表的方法
修改user表中的Host:
update user set Host='%' where User='root';

第二種:授權的方法:將上面代碼換為授權的代碼即可;
grant all privileges on *.* to root@'%' identified by '密碼' with grant option;
最后刷新一下:
flush privileges;

2.設置mysql允許外部連接訪問(修改表的方法):
update user set Host='%' where User='root'; flush privileges;
到此這篇關于如何設置mysql允許外部連接訪問的文章就介紹到這了,更多相關mysql允許外部連接訪問內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

