Home >Database >Mysql Tutorial >How to solve the MySQL prompt 'too many connections' error
When I recently used mysql5.7 to connect to the company's system database, I found an error message and a mysql too many connection exception. After querying, I learned that the error was caused by the number of connections exceeding the default configuration of the mysql system.
1. First log in to the mysql terminal and enter show variables like max_connections to view the maximum number of connections.
Modify the maximum number of connections: set GLOBAL max_connections=1000. After configuring, check the maximum number of connections again.
#2. The reason for exceeding the number of connections is that the number of mysql connections is maintained for too long. You can modify itThe keep-alive mechanism show global variables like 'wait_timeout', which is the maximum sleep time.
Modify set global wait_timeout=300; to automatically kill the thread.
The changes made are only temporary and will be reset if MySQL is restarted. You can modify the mysql configuration /etc/my.cnf.
group_concat_max_len = 10240 # 最大睡眠时间 wait_timeout=300 # 超时时间设置 interactive_timeout = 500
After the modification is completed, restart mysql5.7.
Find MySQL in the task manager, right-click and restart.
The reason is because the underlying Linux operating system limits the number of file handles that a process can open to 1024, resulting in the maximum number of mysql connections being 214
The above is the detailed content of How to solve the MySQL prompt 'too many connections' error. For more information, please follow other related articles on the PHP Chinese website!