当前位置:   article > 正文

mysql 提示 too many connections解决方法_mysql -uroot -p 出错too many connections

mysql -uroot -p 出错too many connections

1、登陆数据库所在服务器,重启mysql

service mysqld restart
  • 1

2、使用命令重新登陆

-- 1、使用命令登陆mysql
mysql -u root -p
-- 2、输入连接密码
-- 3、查看连接数,可以发现有很多连接处于sleep状态
show processlist;
-- 4、查看最大连接数
show variables like "max_connections";
-- 5、修改最大连接数
set GLOBAL max_connections=5000;
-- 6、查看等待秒数
show global variables like 'wait_timeout';
-- 7、修改这个数值,这里可以随意,最好控制在几分钟内
set global wait_timeout=300;
-- 8、关闭一个连接之前要等待的秒数,但是正在使用的连接到了时间也会被关闭
set global interactive_timeout=500;
-- 9、 需要kill的连接id都查询出来
select concat('KILL ',id,';') from information_schema.processlist where user='root'; 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

至此结束,留作日后参考

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/337162
推荐阅读
相关标签
  

闽ICP备14008679号