目录

chen 的个人博客

VX:ZzzChChen
Phone:13403656751
Email:zxydczzs@gmail.com

X

Navicat连接数据库报错 Host XXX is not allowed to connect to this MySQL server

image.png

因为 mysql 配置了不支持远程连接引起的

解决

1、在服务器中登录 mysql root 用户

1mysql -u root -p

image.png

2、依次执行命令

1use mysql;
2
3select host from user where user='root';

image.png

3、将 host 设置为通配符

Host 列指定了允许用户登录所使用的 IP,比如 user=root Host=192.168.1.1。这里的意思就是说 root 用户只能通过 192.168.1.1 的客户端去访问。 user=root Host=localhost,表示只能通过本机客户端去访问。而 % 是个通配符,如果 Host=192.168.1.%,那么就表示只要是 IP 地址前缀为“192.168.1.”的客户端都可以连接。如果 Host=%,表示所有 IP 都有连接权限。

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

image.png

4、修改完成后执行 flush privileges 使配置立即生效

1flush privileges;

image.png

5、再次使用 navicat 连接测试。

image.png


标题:Navicat连接数据库报错 Host XXX is not allowed to connect to this MySQL server
作者:zzzzchen
地址:https://www.dczzs.com/articles/2022/02/17/1645078082394.html