Saturday, 15 September 2018

How to resolve “Too many connections” Error MySQL



The “too many connections” error occur when maximum number of clients may be connected to the server has been reached maximum number of connections that are allowed in MySQL configuration. The default value is 151 for the variable max_connections in MySQL.
Run the following command the check the number connection value:

[root@linuxcnf ~]# mysql –u root –p
mysql> SHOW VARIABLES LIKE 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 151   |
+-----------------+-------+
1 row in set (0.12 sec)

mysql>

To increase the value parameter max_connections in MySQL configuration file /etc/my.cnf and restart MySQL service to reflect the change.

[root@linuxcnf ~]# vi /etc/my.cnf
…..
max_connections = 512

Post the changes restart the MySQL service to reflect the changes:

[root@linuxcnf ~]# service mysqld restart

Post restarting the service verifies the changes:

[root@linuxcnf ~]# mysql –u root –p
mysql> SHOW VARIABLES LIKE 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 512   |
+-----------------+-------+
1 row in set (0.12 sec)

mysql>

It is done!

No comments:

Post a Comment