Mysql连接报错:1130-host ... is not allowed to connect to this MySql server如何处理

我在清除多余数据库用户,只保留root的localhost和127.0.0.1的时候,发现Navicate连接出错;

这个问题是因为在数据库服务器中的mysql数据库中的user的表中没有权限(也可以说没有用户);

(亲测可用!)

  遇到这个问题首先到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;

 

  Mysql连接报错:1130-host ... is not allowed to connect to this MySql server如何处理

  遇到这个问题首先到mysql所在的服务器上用连接进行处理

  连接服务器: mysql -u root -p

  Mysql连接报错:1130-host ... is not allowed to connect to this MySql server如何处理

  查看当前所有数据库:show databases;

  Mysql连接报错:1130-host ... is not allowed to connect to this MySql server如何处理

  进入mysql数据库:use mysql;

  Mysql连接报错:1130-host ... is not allowed to connect to this MySql server如何处理

  查看mysql数据库中所有的表:show tables;

  Mysql连接报错:1130-host ... is not allowed to connect to this MySql server如何处理

  查看user表中的数据:select Host, User,Password from user;

  Mysql连接报错:1130-host ... is not allowed to connect to this MySql server如何处理

  修改user表中的Host:update user set Host='%' where User='root';

  Mysql连接报错:1130-host ... is not allowed to connect to this MySql server如何处理

  最后刷新一下:flush privileges;

  Mysql连接报错:1130-host ... is not allowed to connect to this MySql server如何处理

  重新在Navicate中测试一下:

  Mysql连接报错:1130-host ... is not allowed to connect to this MySql server如何处理