1. 程式人生 > >Mysql連線報錯:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server

Mysql連線報錯:1130 - Host ‘118.111.111.111’ is not allowed to connect to this MariaDB server

 

 

 

這個問題是因為在資料庫伺服器中的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;

 

上面localhost表示只允許本地連線,不能遠端連線

 

 

 

  6、修改user表中的Host:update user set Host='%' where User='root' and Host="localhost";

 

  7、最後重新整理一下:flush privileges;

 

 

  8、重新在Navicate中測試一下: