Error: 1040, Too many connections (MySQL)
Error 1040 occurs when the number of connected clients has reached the value of the max_connections server variable. Follow the solution below to resolve the issue.
First, you should ensure that your applications are closing connections to the server when they are no longer needed. However, you can solve this error by increasing the value of max_connections variable and possibly decreasing the value of wait_timeout if you expect that many of the connections to your server are not being actively used. You can also use the kill command to terminate an open connection. You can find a connection’s internal ID by using the SHOW PROCESSLIST statement and then terminate it like so:
Information about connections to a server can be found using the SHOW STATUS statement like so:
SHOW STATUS LIKE 'max_used_connections';
A high value for Aborted_clients can show that you need more carefully to close database connections in your applications. The value of Max_used_connections can be monitored preventatively to determine whether or not you might need to raise the value of max_connections. More information about the SHOW STATUS statement and this error can be found in the MySQL Manual (see external resources links in margin).