Question
How to increase the max_connections system variable in MySQL? The default value is 151.
Answer
In order to increase this value temporarily, you can log into MySQL from the command line:
mysql
You need to replace the username and the password section with appropriate values.
And then run this command: (You can choose your own number):
set global max_connections = 200;
And then confirm the change by running this command:
mysql> show variables like "max_connections";
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 200 |
+-----------------+-------+
1 row in set (0.01 sec)
However, this change is not permanent and it will not survive the next reboot. To make these changes permanent you need to add the following line to your main MySQL configuration file at /etc/my.cnf:
max_connections=200
And then restart MySQL by like this:
/scripts/restartsrv_mysql --restart