目录

大橙子

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用户

mysql -u root -p

image.png

2、依次执行命令

use mysql;

select 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都有连接权限。

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

image.png

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

flush 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