Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Resolve MySQL error “Too Many Connections”  (Read 2440 times)

0 Members and 1 Guest are viewing this topic.

joseletk

  • Guest
Resolve MySQL error “Too Many Connections”
« on: July 07, 2018, 04:54:31 pm »
There are two ways using which we can resolve this error. We can either increase the number of mysql connections for the current session or we can make changes to increase the number of mysql connections permanently.

1. Increasing mysql connections for current session

Before we make changes to increase the number of mysql connections, we will check the current number of configured mysql connections. To check it, connect to mysql from your terminal,

Code: [Select]
$ mysql –u root –p
Enter the password to connect to mysql & once connected, execute the following command,

Code: [Select]
mysql> SHOW VARIABLES LIKE “max_connections”;
This will bring the max number of connections configured on the screen as output. Its usually 151 by default & we will now increase the value to 1000. To do so , run the following command from mysql terminal only,

Code: [Select]
mysql> SET GLOBAL max_connections = 1000;
Our maximum mysql connections value has now been increased to 1000 but its for current session only. As soon as we restart the mysql service or restart the system, this value will reset to default.

2. Increasing mysql connections for permanently

To increase the number of mysql connections permanently, we need to edit the mysql configuration file I.e. ‘/etc/my.cnf’. Open the file,

$ sudo vim /etc/my.cnf

& make the following entry in the file,

Code: [Select]
max_connections = 1000
Now save the file & exit, than restart the mysql service to implement the changes.

$ sudo systemctl restart mysqld

==========================================================================