message from server: "Host 'XXX.XXX.XXX.XXX' is not allowed to connect to this MySQL server

在连接本机的mysql 数据库时,配置连接信息,连接发生错误,提示:message from server: "Host 'DESKTOP-4OMV7N8' is not allowed to connect to this MySQL server

但是将IP地址改为localhost又能正常连接到MySQL数据库。

临时处理方案:

1、先用localhost方式连接到MySQL数据库,然后使用MySQL自带的数据库mysql;

          use mysql; 


2、执行:select host from user where user = 'root';  发现,host的值就是localhost。

     所以将它的值改掉:update user set host='%' where user = 'root'; 

message from server: "Host 'XXX.XXX.XXX.XXX' is not allowed to connect to this MySQL servermessage from server: "Host 'XXX.XXX.XXX.XXX' is not allowed to connect to this MySQL server

3、修改完成后,执行:flush privileges;  

     将修改内容生效,再次配置时,用IP地址或者localhost 就都能正常连接到MySQL数据库了。

转载自:https://blog.****.net/lsxy117/article/details/47207567