How to fix “Cannot connect to MySQL server (10060)”?

How to fix “Cannot connect to MySQL server (10060)”?

We often used to access MySQL remotely, in some cases, it won’t allow us to connect remotely. It may throw an error by saying

“Cannot connect to MySQL server (10060)”

There are more reasons to cross-check such as downtime in MySQL service and restrictions on the firewall. If the host connection responds at a specific time, you won’t get an error in connecting MySQL remotely.

Downtime in service: This is the most common reason why the user tries to connect MySQL during its downtime. It may be of few problems in MySQL such as DDoS attacks, outages in resources, and heavy traffic spikes.

Let’s start to fix this problem immediately:

Please take confirmation on the server running with the netstat command:

Code:
netstat -plan | grep :3306
If you didn’t get a response or server, get a failure, the dead process will be killed and again it tries to restart the service. For downtime, check the error that occurs in server logs and sort out the problem.

Issues in MySQL configuration:

Only from the localhost, does MySQL responds to the connection.

bind-address 127.0.0.1

With the help of localhost, MySQL will receive the error.

Go to /etc/MySQL/my.cnf configuration file and check whether there is an option to access the remote control.

If you didn’t find the remote enablement, just change the value bind-address to 0.0.0.0 only so, that you will get connected to all the connections.

bind-address 0.0.0.0

You can even set the parameter value for bind-address to make remote access. There is a chance for MySQL listen to the service:


bind-address database-IP

Once you run this command, MySQL starts to listen to the IP address of the server. So, to confirm the changes do MySQL service restart.

Before making any changes, kindly take a backup without fail. If something gets terrible, this backup will help you a lot.

Restrictions in Firewall:

You might have checked the firewall open port 3306 hasn’t opened. So, you won’t get connected to other connections outright!

To confirm the failure of a connection in the remote, check it's only because of the firewall. Just disable the firewall and try to connect again. For cross-checking external connectivity, use command telnet in /etc/mysql/my.cnf :

telnet xx.xx.xx.xx 3306

In case, if you get any connectivity interference from the firewall, making changes in settings can help you.

Windows users:

Step 1:
Tap on the start button and select the control panel to choose “system & security”.

Step 2: Now, select “Windows Firewall” and then “Exception”.

Step 3: You can add the port now.

Ubuntu users:

Use the command to open the MySQL port: ufw allow 3306

Remote users won’t have privileges:

First of all, a remote user should have permission to access MySQL.

Code:
GRANT ALL ON *.* to 'user'@'host_name' identified by 'Password';
FLUSH PRIVILEGES;
Root users have so many privileges to access MySQL. So, as a root user, the server of MySQL leaves a way for you to connect remotely.

To whitelist the IP address or remote host, go to cPanel and then choose “database” to select “remote MySQL”

MySQL connection string entered wrongly:

With the MySQL connection string, you can connect to the MySQL server. In case, if the string was wrong of course, you will get the error right! Your whole connection may get blocked by port, username, database name, and server name if entered wrongly.

The client can give full details on a string. Start configuring the ODBC to the server for comparing the new one with the old string. If the result is matched, your connection will be easy in remote, or else you will get an error.

Try to resolve the matching condition for the strings.

Your problem will be solved!
Author
kumkumsharma
Views
11,611
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from kumkumsharma

Top