2003 - Can't connect to MySQL server on '192.1 68.1 60.136' (10060 "Unknown error")

本机用Navicat连接 CentOS7虚拟机中的MySQL5.7数据库报错,如下:
2003 - Can’t connect to MySQL server on ‘192.1 68.1 60.136’ (10060 “Unknown error”)

2003 - Can't connect to MySQL server on '192.1 68.1 60.136' (10060
查看是否有mysql容器

Docker常用命令

docker ps

进入容器以命令交互

docker exec -it mysql /bin/bash

登录mysql

mysql -uroot -p

执行命令(root改为自己的密码)

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
// %:表示从任何主机连接到mysql服务器

刷新

FLUSH PRIVILEGES;

2003 - Can't connect to MySQL server on '192.1 68.1 60.136' (10060
如果此时还连接出错,那么检查防火墙是否关闭

systemctl status firewalld.service

关闭防火墙

systemctl stop firewalld.service

关闭防火墙开启自启

systemctl disable firewalld.service

2003 - Can't connect to MySQL server on '192.1 68.1 60.136' (10060
此时就可以正常连接了
2003 - Can't connect to MySQL server on '192.1 68.1 60.136' (10060

你可能感兴趣的:(Docker)