mysql不支持远程连接,报错误: ERROR 1130: Host * is not allowed to connect to this MySQL server
解决方法:将localhost修改为%
1、登录mysql(Linux系统)
mysql -u root -p 密码
2、选择mysql数据库
mysql> use mysql;
3、 查看mysql库中的user表的host值(即可进行连接访问的主机/IP名称)
mysql> select host from user where user='root';
+-------------------------+
| host |
+-------------------------+
| 127.0.0.1 |
| ::1 |
| iz2zeiqn00z9x5tiobhi08z |
| localhost |
+-------------------------+
4 rows in set (0.00 sec)
4、更改“mysql”数据库里的“user”表里的“host”项,从”localhost”改为'%'。
update user set host='%' where user='root';
修改host值(以通配符%的内容增加主机/IP地址,当然也可以直接增加某个特定IP地址,如果执行update语句时出现ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 错误,需要select host from user where user = 'root';
查看一下host是否已经有了%这个值,如果有了直接执行下面的flush privileges;即可)
5、重新加载权限
mysql> flush privileges;
6、查看权限
mysql> select host,user from user where user='root';
+-------------------------+------+
| host | user |
+-------------------------+------+
| % | root |
| 127.0.0.1 | root |
| ::1 | root |
| iz2zeiqn00z9x5tiobhi08z | root |
+-------------------------+------+
4 rows in set (0.00 sec)
mysql> quit;