1130 -Host 'ip' is not allowed to connect to this MySQL server

 

 由于mysql默认不允许其他IP地址(非虚拟机)访问

可以将访问的用户(如root)的host 由localhost(本机)改成%(任意,也可指定ip)

最后flush privileges刷新权限

 

[root@hadoop4 ~]# mysql -uroot -p

mysql> use mysql;

mysql> select host,user from user;
+-----------+------+
| host | user |
+-----------+------+
| 127.0.0.1 | root |
| ::1 | root |
| hadoop4 | root |
| localhost | root |
+-----------+------+
4 rows in set (0.01 sec)

mysql> update user set host='%' where user='root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> select host,user from user;
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| 127.0.0.1 | root |
| ::1 | root |
| hadoop4 | root |
+-----------+------+
4 rows in set (0.00 sec)

 

posted @ 2023-04-05 18:06  yappleorange  阅读(73)  评论(0编辑  收藏  举报