I get the error: “Could not connect to SQL database. Too many connections”.

Symptoms

Sometimes I get the “Too many connections” error in Plesk CP or when open a site in my browser:

Cause

This error means that the limit of simultaneous MySQL connection to mysql server is reached and new connections to the server cannot be established at this time.

Resolution

There are two ways to solve this issue. The first one is increase the connection limit and the second, find what is the reason of “too many connection” error and try to lower MySQL server usage.

MySQL server state can be checked using ‘mysqladmin’ utility. For example to find out the number of current connections to the server use:

Current connections limit settings can be found with:

In the example above, maximum number of connections to the server (max_connections) is set to 100. And maximum number of connections per user (max_user_connections) to zero, that means unlimited. There are default MySQL values. They can be redefined in /etc/my.cnf, for example:

Restart MySQL after my.cnf is modified.

Note, if you set connections limit to very high value (more than 300) it may affect the server performance. It is better to find out the reason of the high MySQL server usage. You may check what users/requests slow mysql and take all curent connections, for example with the command:

Please follow and like us:
About shk

shk is a DevOps engineer with more than 12 years of experience in different organizations. He enthusiastic about learning new technologies and shares his knowledge through his blogs.

Comment Policy:

Your words are your own, so be nice and helpful if you can. Please, only use your real name, not your business name or keywords. Using business name or keywords instead of your real name will lead to the comment being deleted. Anonymous commenting is not allowed either. Limit the amount of links submitted in your comment. We accept clean XHTML in comments, but don't overdo it please.

Tell us what you're thinking...

All comments are moderated.

* Denotes required field.

*

*

Previous Post:
Next Post: