Home > Database > Mysql Tutorial > How to solve the MySQL prompt 'too many connections' error

How to solve the MySQL prompt 'too many connections' error

WBOY
Release: 2023-06-03 16:27:46
forward
7453 people have browsed it

Discover the problem

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.

Solution process

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.

How to solve the MySQL prompt too many connections error

#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.

How to solve the MySQL prompt too many connections error

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
Copy after login

How to solve the MySQL prompt too many connections error

After the modification is completed, restart mysql5.7.

How to solve the MySQL prompt too many connections error

Find MySQL in the task manager, right-click and restart.

The reason why mysql limits the maximum number of connections

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

How to solve the MySQL prompt too many connections error

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template