mysql無法遠端訪問解決

2021-08-19 14:46:41 字數 1062 閱讀 2689

mysql資料庫不允許從遠端訪問怎麼辦?本文提供了三種解決方法:

1、改表法。可能是你的帳號不允許從遠端登陸,只能在localhost。這個時候只要在localhost的那台電腦,登入mysql後,更改 "mysql" 資料庫裡的 "user" 表裡的 "host" 項,從"localhost"改稱"%"

mysql -u root -pvmwaremysql>use mysql;

mysql>update user set host = '%' where user = 'root';

mysql>select host, user from user;

2、授權法。例如,你想myuser使用mypassword從任何主機連線到mysql伺服器的話。

grant all privileges on *.* to 'myuser'@'%'identified by 'mypassword' with grant option;

如果你想允許使用者myuser從ip為192.168.1.6的主機連線到mysql伺服器,並使用mypassword作為密碼

grant all privileges on *.* to 'myuser'@'192.168.1.3'identified by

'mypassword' with grant option;

我用的第乙個方法,剛開始發現不行,在網上查了一下,少執行乙個語句 mysql>flush rivileges

使修改生效,就可以了

另外一種方法:

在安裝mysql的機器上執行:

1、d:\mysql\bin\>mysql -h localhost -u root

//這樣應該可以進入mysql伺服器

2、mysql>grant all privileges on *.* to 'root'@'%'with grant option

//賦予任何主機訪問資料的許可權

3、mysql>flush privileges

//修改生效

4、mysql>exit

//退出mysql伺服器

這樣就可以在其它任何的主機上以root身份登入啦0

解決MySQL無法遠端訪問的方法

關閉 開啟red hat防火牆 關閉防火牆 service iptables stop 開啟防火牆 service iptables start 預設關閉防火牆 chkconfig iptables off 授權法。例如,你想myuser使用mypassword從任何主機連線到mysql伺服器的話。...

解決MySQL無法遠端訪問的方法

關閉 開啟red hat防火牆 關閉防火牆 service iptables stop 開啟防火牆 service iptables start 預設關閉防火牆 chkconfig iptables off 授權法。例如,你想myuser使用mypassword從任何主機連線到mysql伺服器的話。...

無法遠端訪問Mysql的解決方案

1。改表法。可能是你的帳號不允許從遠端登陸,只能在localhost。這個時候只要在localhost的那台電腦,登入mysql後,更改 mysql 資料庫裡的 user 表裡的 host 項,從 localhost 改稱 code mysql u root p123 mysql use mysql...