mysql 连接错误码1130(not allowed to connect to this MySQL server)解决

1. win + R  输入cmd

2.在安装Mysql数据库的主机上登录:

如 root用户

   输入命令   mysql -u root -p

 

  输入密码后

 

 3. 

use mysql;

 注意:语句结束需要封号(;)

 

 

4.

select host from user where user = 'root';

 注意:语句结束需要封号(;)

看查询出来的host是否有需要连接本数据的ip地址

结果可能要两种情况

>>1.只有localhost

    将Host设置为通配符%

    (%是个通配符,如果Host=127.0.1.%,那么就表示只要是IP地址前缀为“127.0.1.”的客户端都可以连接。如果Host=%,表示所有IP都有连接权限)

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

>>2.除了localhost还有其它的ip

 

 这时候修改其中一条即可(例如localhost)

update user set host='%' where user='root' and user = 'localhost';  

5.最后刷新一下:flush privileges;

就可以了

posted @ 2021-12-11 17:45  巴适的哼  阅读(1720)  评论(1编辑  收藏  举报