navicat连接mysql报错1130-host ... is not allowed to connect to this MySql server的解决办法
navicat连接mysql报错1130-Host '1xxx.xx.x.20' is not allowed to connect to this MySQL server的解决办法
原因:没有权限
解决办法:
1、连接服务器: mysql -u root -p
2、看当前所有数据库:show databases;
3、进入mysql数据库:use mysql;
4、查看mysql数据库中所有的表:show tables;
5、查看user表中的数据:select host, user from user;
6、修改user表中的Host:update user set host='%' where user='root';
7、最后刷新一下:flush privileges;
修改前后:
%的意思:
Host列指定了允许用户登录所使用的IP,比如user=root Host=192.168.1.1。这里的意思就是说root用户只能通过192.168.1.1的客户端去访问。
而%是个通配符,如果Host=192.168.1.%,那么就表示只要是IP地址前缀为“192.168.1.”的客户端都可以连接。如果Host=%,表示所有IP都有连接权限。、
这也就是为什么在开启远程连接的时候,大部分人都直接把Host改成%的缘故,为了省事。