Tag Archives: MYSQL Remote connection 2003 Error

[Solved] MYSQL Remote connection 2003 Error: can’t connect to MYSQL server on ”(10060)

Date: November 17, 2017

Problem: error in remote connection to MySQL database: 2003 can’t connect to MySQL server on ” (10060)

Reason: the alicloud console does not open port 3306 in the instance security group

How to discover: discovered when using Navicat to connect to remote database

Repair: open the alicloud console and add port 3306 to the instance security group

In which files have been modified: the alicloud console has been modified

I lead to: No

Bug resolution time: 2 hours

Lesson: because I was just beginning to learn Java, I didn’t think that it was a problem on the Alibaba cloud server console when this problem occurred. I checked a lot of information on the Internet, There are three similar solutions: 1. Port 3306 is not opened on the remote server; 2. Your IP is not authorized to log in to the remote database (or your database account refuses to log in remotely); 3. The network is blocked

The solution to the first problem is:

Opening port 3306 in iptables

#/sbin/iptables-IINPUT-ptcp–dport3306-jACCEPT

#/Etc/rc.d/init.d/iptablessave:

#Service iptables restart takes effect

The second solution is:

Set remote user access rights:

//Any remote host can access the database

mysql> GRANTALLPRIVILEGESON*.*TO’root’@’%’WITHGRANTOPTION;

//You need to enter a command for the modification to take effect

mysql> FLUSHPRIVILEGES;

//Exit

mysql> EXIT

The third is not explained

(another way is to turn off the server firewall:

#

This method is not recommended for serviceiptables stop, which may cause unknown security problems.)

Obviously, it didn’t solve the problem in the end. A lot of information on the Internet is repetitive. In the end, there is no way. I found that it was the problem on the Alibaba cloud console with the help of my elder martial brother. It shows that I’m still thinking in the wrong direction

Open ECS

Open an instance of the menu on the left

Open the management on the far right of the instance

Open the security group of this instance in the menu on the left

Open the configuration rule on the right

Add security group rule in upper right corner

The protocol type is customized by default, the port range is 3306/3306, the authorization object is 0.0.0.0/0, and others are OK by default

Confirm and restart the server

Connect OK!