Too many connections error in MySQL
Last updated on: 2021-07-01
Authored by: Ivan Arteaga
The too many connections error appears when attempting to connect to a server and the available connections, set to 100 by default, are in use already.
Keep in mind that MySQL® has a variable max_connections +1 for client connections, the +1 is dedicated for accounts with CONNECTION_ADMIN privileges.
Perform the following steps to fix this issue:
Identify the max_connections variable value:
mysql --user="root" --password="PASSWORD" --execute='SHOW VARIABLES LIKE "max_connections";
The output looks like this:
Variable_name Value max_connections 100
Use your favorite text editor to change /etc/mysql/my.cnf and set the following values:
max_connections = 500
max_user_connections = 500
Note: Increasing the amount of possible connections directly affects the amount of RAM consumed.
mysql --helpcan help locate the my.cnf file because it displays default options on the following files:
Restart the MySQL service and to apply the changes.