Monday, 25 April 2016

How to change max_connections setting in MySQL



Error:  "too many connections"

Solution:The default setting for max_connections is 151.
You can see what the current setting is by below command from the Mysql consol:

mysql> show variables like "max_connections";

This will return a output as like below:

mysql> show variables like "max_connections";
+------------------------+---------+
| Variable_name     | Value |
+------------------------+---------+
| max_connections | 150      |
+------------------------+---------+
1 row in set (0.00 sec)
mysql>

You can change the setting from 151 connections to 251 by issuing the below command from the Mysql console:

mysql> set global max_connections = 250;
mysql>

This will take effect immediately, but it’s temporary changes, when you restart Mysql service it will removed.

To make the change permanent add the below line /etc/my.cnf in mysqld section and restart the Mysql service.

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


No comments:

Post a comment