mysql远程的登陆常见错误
远程登录mysql 报错 ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.137.105' (113)
防火墙问题 :服务器上firewalld没有开放mysql 占用的端口3306
firewall-cmd --zone=public --add-port=3306/tcp --permanent
systemctl restart mysql
远程登录mysql时报错ERROR 1130 (HY000): Host '192.168.137.105' is not allowed to connect to this MySQL server
问题原因:mysql服务器出于安全考虑,默认只允许本地登录数据库服务器。
问题解决:登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%",然后重启mysql这样就允许所有的远程机器进行访问了。
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set host = '%' where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> select host, user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| % | root |
| localhost | mysql.session |
| localhost | mysql.sys |
+-----------+---------------+
3 rows in set (0.00 sec)
重启mysql

浙公网安备 33010602011771号