How to fix “Too Many Connection” Error in MySQL

 

 

 

In this article we will help to solve “Too Many Connection” error. In Linux based servers It will show connection error in MySQL . To resolve this issue  you need to increase the value of max_connection.

 

You can download the latest version of Putty SSH client by clicking below link

Click here  for 32-bit.

Click here for 64-bit.

After that, Install it on your computer to make your SSH connection.

 

Before you proceed, These are basic commands kindly click Commands Link

Check max_connection value

To check the value of max_connection you need to login on mysql terminal with root privileged user.

 

# mysql - root -p                                                                                                                                                                                                                                                   
 mysql> SHOW VARIABLES LIKE "max_connection";

 

+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 200 |
+-----------------+-------+
1 row in set (0.00 sec)

 

Update max_connections value 

We can update the max_connection values as below

Temporary changes

Before changing the value , make sure you server have enough resources to handle more connection. Run the below command from mysql with root privileged user.

#mysql> SET GLOBAL max_connection =400;

After restarting MySQL service value will be reset.

Permanent Changes

To set value permanently you need to add variables in mysql configuration file on your server. By default Mysql configuration file is  /etc/my.cnf but on some server mysql configuration file is /etc/mysql/my.cnf.

 

# nano /etc/my.cnf                                                                                                                                                                                                                                             
 or                                                                                                                                                                                                                                                                            
# nano /etc/mysql/my.cnf

 

max_connection = 400

 

After adding the variables in MySQL configuration file restart MySQL service to reflect the changes.

# service mysqld restart

 

Enjoy it

Leave a Reply

Your email address will not be published. Required fields are marked *