Wednesday, August 29, 2018

How to set up MySQL max connections

This shows current max connections for mysql.
mysql> show variables like 'max_connections';

This shows current used connections for now.
mysql> show status like 'Max_used_connections';

To check how many connections were aborted. If you see aborted connection, you might need to increase max connection settings.
mysql> show status like 'Aborted%';

To change max connections:
mysql> set global max_connections=300;

If you want permanent settings:
# vi /etc/my.cnf
max_connections = 300

You need to restart to make the change of /etc/my.cnf to be effective.
service mysqld restart

and check it again:
mysql> show variables like 'max_connections';