If you ever receive the error “Too many connections” (too many connections) on your page when it attempts to connect to the MySQL service, this means that all available connections are already in use.
Steps to increase the connection limit
The first thing you need to do is connect to your Linux Server via SSH. If you do not know how to do this, see the article titled Access Linux via SSH with PuTTY.
Once connected, edit the file /etc/my.cnf:
# vi/etc/my.cnf
You will see a section like this (or similar):
[mysqld]
safe-show-database
innodb_data_file_path=ibdata1:10M:autoextend
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
Add the following line below the [mysqld] section if, for example, you want to increase the limit to 250 connections:
max_connections=250
It should look like this:
[mysqld]
safe-show-database
innodb_data_file_path=ibdata1:10M:autoextend
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
max_connections=250
Once you have saved the changes, restart the service:
# /etc/init.d/mysqld restart
To check that everything worked correctly, access the MySQL console:
# mysql -uadmin -p`cat /etc/psa/.psa.shadow`
Finally, run the following command:
show variables like 'max_connections';
And that's it! This should resolve the problem of too many connections. If it keeps happening, consider increasing the server's resources a little to see if that resolves it.