Tips & Tricks

How to increase the MySQL max connections?

This will show you how to increase the max connections variable in MySQL.

When you see the error message on your web site that you are exceeding the MySQL max connections to the database you will need to increase the number in my.cnf.
Note: my.cnf is the configuration file of MySQL.

Usually this file is located at /etc/my.cnf but in the different *nix distributions it can be on a different location.
To increase the max connections variable you will need to edit this file.

Open the file and include the following line under the [mysqld] section:
set-variable = max_connections=XXX
Note: XXX must be replaced with a number of the max allowed connections.

set-variable = max_connections=500

In this example we have increased the max connections to 500.

Once this is done you will need to restart the MySQL service. Usually this is done using the command:
/etc/init.d/mysqld restart

Good luck!

Leave a Reply