由于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)
标签:set,allowed,ip,1130,+-----------+------+,host,user,mysql,root From: https://www.cnblogs.com/yappleorange/p/17290185.html