Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mySQL Error 1040: Too Many Connection

How to fix these, "SQL Error 1040: Too Many Connection" even I try to put

max_user_connection=500 

still "Too many connection"

like image 590
kelvzy Avatar asked Jan 15 '13 04:01

kelvzy


People also ask

How do I fix MySQL error 1040 too many connections?

This means that the maximum number of clients that may be connected to the server has been reached. Either the client will have to wait for another client to log off, or the administrator will have to increase the maximum number of connections allowed.

How does MySQL handle too many connections?

If clients encounter Too many connections errors when attempting to connect to the mysqld server, all available connections are in use by other clients. The permitted number of connections is controlled by the max_connections system variable. To support more connections, set max_connections to a larger value.

How many MySQL connections can handle?

How Many Connections can MySQL handle? By default, MySQL 5.5+ can handle up to 151 connections. This number is stored in server variable called max_connections.


1 Answers

MySQL: ERROR 1040: Too many connections

This basically tells that MySQL handles the maximum number of connections simultaneously and by default it handles 100 connections simultaneously.

These following reasons cause MySQL to run out connections.

  1. Slow Queries

  2. Data Storage Techniques

  3. Bad MySQL configuration

I was able to overcome this issues by doing the followings.

Open MySQL command line tool and type,

show variables like "max_connections"; 

This will return you something like this.

+-----------------+-------+ | Variable_name   | Value | +-----------------+-------+ | max_connections | 100   | +-----------------+-------+ 

You can change the setting to e.g. 200 by issuing the following command without having to restart the MySQL server.

set global max_connections = 200; 

Now when you restart MySQL the next time it will use this setting instead of the default.

Keep in mind that increase of the number of connections will increase the amount of RAM required for MySQL to run.

like image 160
Dulith De Costa Avatar answered Oct 08 '22 06:10

Dulith De Costa