host 192.168.1.152 is not allowed to connect to this MySQL server

message from server: "Host ‘192.168.1.152’ is not allowed to connect to this MySQL server

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

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

解决办法:

在navicat中执行以下命令

select host from user where user = 'root'

发现,host的值就是localhost
所以要修改它的值:

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

修改完成后,执行

flush privileges

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

猜你喜欢

转载自blog.csdn.net/qq_40145879/article/details/106838193