Mysql連線報錯:1130-Host is not allowed to connect to this MySQL server
阿新 • • 發佈:2022-12-09
這個問題是因為在資料庫伺服器中的mysql資料庫中的user的表中沒有許可權(也可以說沒有使用者),下面將記錄我遇到問題的過程及解決的方法。
在搭建完LNMP環境後用Navicate連接出錯
遇到這個問題首先到mysql所在的伺服器上用連線進行處理
1、連線伺服器: mysql -u root -p
2、看當前所有資料庫:show databases;
3、進入mysql資料庫:use mysql;
4、檢視mysql資料庫中所有的表:show tables;
5、檢視user表中的資料:select Host, User,Password from user;
6、修改user表中的Host:update user set Host='%' where User='root';
7、最後重新整理一下:flush privileges;
#一定要記得在寫sql的時候要在語句完成後加上" ; "下面是圖示說明
遇到這個問題首先到mysql所在的伺服器上用連線進行處理
連線伺服器: mysql -u root -p
檢視當前所有資料庫:show databases;
進入mysql資料庫:use mysql;
檢視mysql資料庫中所有的表:show tables;
檢視user表中的資料:select Host, User,Password from user;
修改user表中的Host:update user set Host='%' where User='root';
最後重新整理一下:flush privileges;
重新在Navicate中測試一下: