Change max_connections in MySQL

Normally, the parameter max_connections in MySQL is set to 151 and allowed for one connection more, that is, there may be 152 connections.
If there are more connections, there will be a “too many connections” error.
On an example I use MySQL 5.5.54.

To increase the value, we connect to MySQL:

mysql -u root -p

Let’s see a list of current connections:

show processlist;
SHOW FULL PROCESSLIST\G
show status where `variable_name` = 'Threads_connected';

Let’s see the current value of max_connections:

show variables like "max_connections";

If you need to increase it without restarting MySQL (it will work before restarting MySQL):

set global max_connections = 300;

So that after the restart of MySQL the value of max_connections is preserved, in the configuration file /etc/mysql/my.cnf, in the [mysqld] section we specify it:

max_connections = 300
Подписаться на IT Blog (RU) по Email
Subscribe to IT Blog (EN) by Email

Did my article help you? How about buying me a cup of coffee as an encouragement? Buy me a coffe.

Leave a Reply