In this tutorial, we will learn How to Check and Update “max_connections” Value in MySQL?
Sometimes your server may experience issues of too many connections in the MySQL server. To fix this you can increase the max_connections value in your MySQL configuration.
Check “max_connections” Value
Max connections values are stored with variable named max_connections. Login to your MySQL terminal with the privileged user and execute the following query.
SHOW VARIABLES LIKE "max_connections";
+-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 150 | +-----------------+-------+ 1 row in set (0.00 sec)
As per the above output max_connections value is set to 150.
Update “max_connections” Value
Before increasing this value, make sure your server has enough resources to handle more queries. Now execute the below query in the MySQL terminal to set this value temporarily. Remember that this value will reset on the next MySQL reboot.
SET GLOBAL max_connections = 250;
To set this value permanently, edit the MySQL configuration file on your server and set the following variable. The configuration file location may change as per your operating system. By default, you can find this at /etc/my.cnf on CentOS and RHEL based system and /etc/mysql/my.cnf on Debian based system.
max_connections = 250
Now restart the MySQL service and check the value again with the above-given command. This time you will see that value is set to 250.
That’s it, this is How to Check and Update “max_connections” Value in MySQL. Feel free to use the comment section in case of any suggestion 😎