mySql連線常見錯誤問題

2021-05-26 02:30:54 字數 1667 閱讀 3076

mysql:is not allowed to connect to this mysql server

如果你想連線你的mysql的時候發生這個錯誤:

error 1130: host '192.168.1.3' is not allowed to connect to this mysql server

解決方法:

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.3的主機連線到mysql伺服器,並使用mypassword作為密碼

grant all privileges on *.* to 'root'@'192.168.1.3' identified by 'mypassword' with grant option;

grant all privileges on *.* to 'root'@'10.10.40.54' identified by '123456' with grant option;

發現出現"host 'localhost' is not allowed to connect to this mysql server" ,真是離奇的事情一件接一見

後來回想了一下發現,因為只是update了root,但是mysql是有個訪問控制表,root的訪問控制表未更新,就導致了無法訪問mysql

網上找到的解決方法,應該是跳過該錶就可以直接使用了,但是這個放在伺服器上還是會有一定的風險,那就是任何人在任何地方都可以訪問你的mysql,如果安全重要的話還是重新裝一下資料庫好了。

解決方法如下:

編輯 my.ini linux下為/etc/my.cnf

例如:[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

skip-name-resolve

skip-grant-tables

目的是為了:

跳過mysql的訪問控制,任何人都可以在控制台以管理員的身份進入mysql資料庫。

需要注意的是在修改完密碼以後要把mysql伺服器停掉重新啟動才會生效

重啟mysql服務!

前面是別人的經歷;以下總結

安裝mysql的連線驅動

修改表資訊 mysql -u root -pvmwaremysql>use mysql;mysql>update user set host = '%' where user = 'root';mysql>select host, user from user;

重啟mysql服務,odbbc連線成功。

mysql 錯誤問題 mysql連線錯誤問題

error 1130 host 192.168.1.3 is not allowed to connect to this mysql server 解決方法 1。改表法。可能是你的帳號不允許從遠端登陸,只能在localhost。這個時候只要在localhost的那台電腦,登入mysql後,更改 m...

Mysql 連線遠端常見錯誤

一.修改root 使用者 host欄位登入到mysql show databases 檢視所有資料庫 use mysql 選中資料庫 修改 mysql 資料庫 下 user 表的 host 字段 update user set host where host localhost and user r...

mysql連線錯誤問題

error 1130 host 192.168.1.3 is not allowed to connect to this mysql server 解決方法 1。改表法。可能是你的帳號不允許從遠端登陸,只能在localhost。這個時候只要在localhost的那台電腦,登入mysql後,更改 m...