在尝试使用pycharm远程连接服务器的mysql时,遇到了
[08S01] Communications link failure.
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
经过如下步骤,问题解决:
1.进入需要远程连接的数据库,更改mysql数据库的user表中的host字段
use mysql;
update user set host='%' where user='root';
select host,user from user;
2.开放端口和关闭防火墙
开放端口
sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
sudo firewall-cmd --reaload
检查新的防火墙规则
firewall-cmd --list-all
也可以直接关闭(临时关闭,重启后开启)防火墙
systemctl restart firewalld