网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 生活知识 知识问答

MySQL提示too many connections解决办法

时间:2024-10-28 04:00:06

1、首先登录mysql终端,查看一下mysql的日志文件存放位置。 show global variables like log。

MySQL提示too many connections解决办法

2、根据提示,找到/var/下的mysql日志看看有没有什么其他错误。

MySQL提示too many connections解决办法

3、若没有其他错误mysql终端,通过输入show variables like max_connections,查看最大连接数。如图151

MySQL提示too many connections解决办法

4、修改最大连接数:set GLOBAL max_connections=1000,配置好之后再次查看最大连接数的量。

MySQL提示too many connections解决办法

5、超过连接数的原因,是mysql的连接数保持时间太长。可以修改一下保活机制show global variables like 'wait_timeout' ,就是最大睡眠时间。

MySQL提示too many connections解决办法

6、修改一下 set global wait_timeout=300; 自动杀死线程。

MySQL提示too many connections解决办法

7、刚刚的配置是临时修改,重启mysql会失效。可以通过修改mysql的配置/etc/my.cnf 添加 max_connections=1000

MySQL提示too many connections解决办法

8、还有超时时间设置,wait_timeout = 300 和interactive_timeout = 500,然后重启mysql服务。

MySQL提示too many connections解决办法
© 2026 海能知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com