mySQL 错误 1040:连接过多

问题描述:

如何解决这些问题,SQL 错误 1040:连接过多"即使我试着把

How to fix these, "SQL Error 1040: Too Many Connection" even I try to put

max_user_connection=500

仍然是连接过多"

MySQL: ERROR 1040: Too many connections

这基本上说明 MySQL 同时处理最大连接数,默认情况下它同时处理 100 个连接.

This basically tells that MySQL handles the maximum number of connections simultaneously and by default it handles 100 connections simultaneously.

以下原因导致 MySQL 连接耗尽.

These following reasons cause MySQL to run out connections.

  1. 慢查询

数据存储技术

错误的 MySQL 配置

Bad MySQL configuration

通过执行以下操作,我能够克服这个问题.

I was able to overcome this issues by doing the followings.

打开MySQL命令行工具并输入,

show variables like "max_connections";

这将返回给你这样的东西.

This will return you something like this.

+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 100   |
+-----------------+-------+

您可以将设置更改为例如200 通过发出以下命令而无需重新启动 MySQL 服务器.

You can change the setting to e.g. 200 by issuing the following command without having to restart the MySQL server.

set global max_connections = 200;

现在当您下次重新启动 MySQL 时,它将使用此设置而不是默认设置.

Now when you restart MySQL the next time it will use this setting instead of the default.

请记住,连接数的增加会增加 MySQL 运行所需的 RAM 量.