Troubleshooting Database Connection Issues
This article lists some reasons why you cannot connect to MySQL remotely and shows you how to solve the remote database connection issues.
1> MySQL service is not running.
2> DB user does not have correct password or permission.
3> Firewall restricts IP connection on the “Security” page.
4> Remote Connection issue between your local server to our MySQL.
5> The MySQL remote connection port is blocked by your server or ISP.
6> Wrong MySQL connection information defined in application.
MySQL service is not running
1) Please check the status on the “Overview” page of your application in the Control Panel.
2)Running the command “ps –ef” via shell interface to check the MySQL status. The service is working if the result is as the following screenshot shows.
If the MySQL service is not working, please use the shell tool in the Control Panel to check MySQL logs. Inputting the command “cd log/”, then “ls -a”, followed by “vi mysql_error.log” to open the log file.
DB user does not have correct password or permission
Open phpMyAdmin in the Control Panel and check the MySQL User permission in phpMyAdmin.
1) If you cannot log in to MySQL via phpMyAdmin and get the following error, the password of the database user might be wrong.
2) If a MySQL user can log in to MySQL via phpMyAdmin, please check if the user has remote connection permission in phpMyAdmin. The option ‘ % ’ means all hosts can connect to MySQL user. While ‘127.0.0.1’ and ‘localhost’ mean the user does not support remote connection.
Firewall restricts IP connection on “Security”
If you have enabled Firewall Rules under the “Security” tab, it will restrict the remote connection. Only the listed IPs will be allowed to connect to your application.
Solution: You can add more allowed IPs to the Firewall(a maximum of 5 IPs or IP ranges).
Or you just stop the Firewall service to allow connections from all IPs.
Remote Connection issue between your local server to our MySQL
We can use “ping” and “tracert” commands on your local computer to test the remote connection.
1. Use Ping to check the connection issue
Get the MySQL package host IP on the Overview page in the Control Panel.
As our MySQL server do not allow ping function. You can ping the gateway of the MySQL package on local PC to test the connection between local PC and MySQL server. If the result is like the following screenshot shows, it is normal. If it shows time out, please check your local network.
2. Use “Tracert” comamnd to check the connection issue
You can use the “tracert” command on most operation system to test the connection.
Mac / Linux:
Please run “yum -y install traceroute” or “apt-get install traceroute” install traceroute first.
1.Open a Terminal window.
<mysqlhostip>" in the terminal and hit enter.
1.Open the Start menu.
2.Click on Run.
3.Type "cmd" and press "OK" to open a command prompt.
<mysqlhostip>" and hit enter.
<mysqlhostip> should be filled in with your MySQL hostname or host IP. If the result is like the following screenshot shows, it is normal. If the tracert process cannot complete, please check your local network.
The MySQL remote connection port is blocked by your server or ISP
We can use telnet command to test if the port is blocked by your server or ISP.
If we want to test if the port 14976 is blocked, we can use “telnet 126.96.36.199 14976” .
If the telnet command cannot be recognized on your local PC, please install a telnet client first.
To install a telnet client,
Centos: # yum -y install telnet
Ubuntu & Debian: # apt-get install telnet
Wrong MySQL connection information defined in the application
Please refer to the article “Connecting to MySQL Database via Different Program Language” to check your database connection information in your codes.