错误码 2003,can't connect to mysql server on xxxx
解决办法:
(1)#查看端口开放情况
# firewall-cmd --list-ports
(2)#开放3306端口
# firewall-cmd --zone=public --add-port=3306/tcp --permanent
(3)#重启防火墙
#systemctl restart firewalld.service
端口开放解决后,连接数据库又报如下错误:
错误码 1130 Host xxxxx is not allowed to connect to this Mysql server
问题原因:mysql未开启mysql远程访问权限。
解决办法:
在linux机器上登录mysql,修改mysql的user表。
(1)查询需要修改的记录
select host, user, password from user where host='localhost' and user='root';
(2)更新
update user set host='%' where host='localhost' and user='root';
(3)刷新权限
FLUSH PRIVILEGES;
以上两个问题解决后,重新连接Mysql,OK。