数据库连接数量我设置了16384,最大值(其实生产环境不要做这么做,会拖垮你的机器)

SET GLOBAL max_connections = 16384;

 对于mysql8在设置一下这个

SET GLOBAL mysqlx_max_connections = 16384;

 如果不记得设置的是多少,可以使用 命令查看自己的设置

SHOW variables like '%max_connections%';

 主要是配置连接关闭时间,参考自https://blog.csdn.net/u013887008/article/details/79491433

 

每个连接默认是28800秒,没啥用,断开了重新连接就是了,节约性能,所以直接设置10秒

查看当前进程的连接时间的命令

show processlist;

 结果中肯定有很多,都是sleep,还是关闭掉比较合理

 网上说修改interactive_timeout 是否可以达到修改wait_timeout的效果,命令 ()

set global interactive_timeout=10;

 意思是空闲10秒后就关闭连接,再查看一下当前的设置情况确认是否生效

SHOW variables like '%timeout';

 mysql过多sleep连接 修改timeout配置节约连接数  配置连接数解决 too many connections

 可以看到已经配置成功了

然后退出mysql

EXIT

 

 重新登录mysql再检查一下

SHOW variables like '%timeout';

 mysql过多sleep连接 修改timeout配置节约连接数  配置连接数解决 too many connections

 配置仍然ok,好了,关闭cli,开始干活吧

相关文章:

  • 2021-11-27
  • 2022-12-23
  • 2021-11-27
  • 2021-09-18
  • 2022-12-23
  • 2021-04-26
  • 2021-09-03
  • 2021-11-27
猜你喜欢
  • 2022-12-23
  • 2021-12-19
  • 2021-10-11
  • 2021-12-11
  • 2021-10-21
  • 2022-02-07
  • 2021-12-30
相关资源
相似解决方案