Recently a lot of overtime, so it is not a long time remote access to your cloud server on MySQL
the database. Today, the local start Node
when the service Rom MySQL
, as usual is used Navicat For MySQL
to connect remote database to check, and found that suddenly the error.
2003-Can’t connect to MySQL server on ‘XXX.XX.XX.XX’(10060)
Check the network
The first reaction was to check the network is not normal, so we immediately ping
test, however, found that not a network problem, you can normally ping
pass.
ping XXX.XX.XX.XX
正在 Ping XXX.XX.XX.XX 具有 32 字节的数据:
来自 XXX.XX.XX.XX 的回复: 字节=32 时间=64ms TTL=47
来自 XXX.XX.XX.XX 的回复: 字节=32 时间=86ms TTL=47
Check the security group
Then take a look at the security group set up to think of cloud servers if there are problems, but did not come out until this issue is unlikely to reason with the security group of problems, but still under check is wonderful.
After logging Tencent cloud, found examples of corresponding security group set up properly properly, there is no problem.
Check the user permissions
Because it is my own server, so the use of all root
users. You need xshell
to log in MySQL
query under user
the table.
mysql -uroot -p
输入密码
mysql> use mysql
mysql> select host,user from user;
+-----------+------------------+
| host | user |
+-----------+------------------+
| % | root |
| localhost | mysql.infoschema |
| localhost | mysql.session |
| localhost | mysql.sys |
+-----------+------------------+
4 rows in set (0.00 sec)
Can be found, root
the corresponding host
Shi %
, any meaning, it means that root
the user is connected MySQL
when not ip
constrained.
So it is not a problem here!
Check the CentOS firewall
It is very easy to overlook one step, many people may think that security groups have been set up, you do not have to check the CentOS
firewall. In fact, it is necessary to check the firewall, we should 3306
put on, and then restart the firewall.
[root@VM_0_14_centos ~]# firewall-cmd --permanent --zone=public --add-port=3306/tcp
success
[root@VM_0_14_centos ~]# firewall-cmd --reload
success
Then a look, very pleasant, Navicat for MySQL
connect to a remote database success!