MySQL Connection Errors and Troubleshooting

This article will assist you to fix the common causes of MySQL connection errors along with steps to resolve them. 

Check If MySQL Server is Running

When you receive MySQL connection errors the first thing you should check is if MySQL server is running or not. MySQL server needs to be started before it accepts the connections from clients. On Windows machines MySQL service can be started from the services control panel (Start >> Run >> type services.msc + enter). On Linux machines MySQL server can be started either through cPanel/WHM or from Linux terminal. You can also check our knowledgebase article on How to start MySQL service in Windows and Linux machines.


Check if MySQL server is listening on the default port

By default MySQL server listens on port 3306 however, it can be changed for each MySQL instance. If you have configured MySQL server to listen to some other port, the same port must be specified while clients connect to MySQL server. To find the port on which MySQL is listening to, check out your mysql configuration file (my.ini or my.cnf).


Check if skip-networking configuration option is enabled in my.ini or my.cnf

Make sure that your MySQL server is not configured to ignore network connections. If the skip-networking option is not commented out in the MySQL configuration file, clients would not be able to connect to MySQL instance via TCP/IP. To turn off the skip-networking option, edit the MySQL configuration file (my.ini or my.cnf), locate the line containing the text skip-networking and comment it out appending with #.


Database username does not have privileges to connect

MySQL database users must have appropriate connection privileges to be able to connect to MySQL instance. These privileges can be specified while you create a database username or else you can edit an existing username and specify necessary permissions. You can directly set permissions from web based MySQL server manager like phpMyAdmin or through Linux terminal. For example, following MySQL statements will give the user dbuser all privileges, including connection privileges (for localhost only).


GRANT ALL PRIVILEGES ON *.* TO 'dbuser'@'localhost';

Following command can be used to give user the dbuser all privileges including the permission to connect remotely.

GRANT ALL PRIVILEGES ON *.* TO 'dbuser'@'localhost' IDENTIFIED BY 'your-password' WITH GRANT OPTION;

bind_address configuration option is set to in my.ini or my.cnf

If the bind_address configuration is set to in the MySQL configuration file, MySQL server won't accept connections from remote hosts. To allow remote connections, you can remove or comment out the line bind_address line in the MySQL configuration file.

Check if firewall is blocking incoming connections to MySQL server

The firewall where the MySQL server resides must be configured to allow transmission via the port on which MySQL is listening. If the MySQL port is blocked in server firewall, the client will not be able to connect. Check out the following articles to open ports in Windows and cPanel/WHM machines.


  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to convert time zone in MySQL?

You can change the timezone in MySQL using php function CONVERT_TZ. Following is the SQL command...

How to connect MySQL using Python?

There are several ways to use python to connect with the MySQL database. In this article, we will...

How do I connect MySQL database via MySQL Workbench?

MySQL Workbench is the excellent MySQL client tool used to connect to remote MySQL database from...

How to Administrate MySQL Server with mysqladmin commands?

By using mysqladmin commands, you can perform basic MySQL tasks very easily, such as...

How to change MySQL root password from WHM?

In this article, we will describe steps to change the root password of MySQL server from WHM....