too many connections 解决方法
来源:互联网 发布:毕向东java教程35天版 编辑:程序博客网 时间:2024/05/16 12:54
最近写javaee项目的时候,mysql报了too many connections的错误,百度的内容有一些有问题,所以我重新写一下我的解决方法。
mysql -u root -p
回车输入密码进入mysqlshow processlist;
查看连接数,可以发现有很多连接处于sleep状态,这些其实是暂时没有用的,所以可以kill掉show variables like "max_connections";
查看最大连接数,应该是与上面查询到的连接数相同,才会出现too many connections的情况set GLOBAL max_connections=1000;
修改最大连接数,但是这不是一劳永逸的方法,应该要让它自动杀死那些sleep的进程。show global variables like 'wait_timeout';
这个数值指的是mysql在关闭一个非交互的连接之前要等待的秒数,默认是28800sset global wait_timeout=300;
修改这个数值,这里可以随意,最好控制在几分钟内set global interactive_timeout=500;
修改这个数值,表示mysql在关闭一个连接之前要等待的秒数,至此可以让mysql自动关闭那些没用的连接,但要注意的是,正在使用的连接到了时间也会被关闭,因此这个时间值要合适批量kill之前没用的sleep连接,在网上搜索的方法对我都不奏效,因此只好使用最笨的办法,一个一个kill
select concat('KILL ',id,';') from information_schema.processlist where user='root';
先把要kill的连接id都查询出来- 复制中间的
kill id;
内容到word文档 - 替换掉符号“|”和回车符(在word中查询^p即可查询到回车符)
- 把修改过的内容复制回终端,最后按回车执行!
0 0
- too many connections 解决方法
- Err: 1040: Too many connections 真正解决方法
- Discuz!出现错误Too many connections解决方法
- Too many connections
- mysql: Too many connections
- mysql Too many connections
- mysql Too many connections
- too many connections
- mysql "too many connections"
- too many connections
- Mysql too many connections
- MySQL too many connections
- too many connections 分析
- mysql "too many connections" 错误 之 mysql解决方法
- Linux 下 mysql :ERROR 1040 (00000): Too many connections解决方法
- mysql "too many connections" 错误 之 mysql解决方法
- MySQL 1040 错误 Too many connections的解决方法
- mysql "too many connections" 错误 之 mysql解决方法
- Android课程表的设计开发
- bzoj 2437: [Noi2011]兔兔与蛋蛋 (二分图博弈+dinic)
- 雏鹰开发附件1 – Spring相关Maven配置
- 控制流如何处理错误
- io原理
- too many connections 解决方法
- Centos7 安装rabbitmq
- 属性名不一致的对象深度克隆
- iOS 视频文件和图片文件缓存路径
- 我们,除了代码还有诗和远方
- 谈谈我对攻读计算机研究生的一些看法
- SQL Server 的本地时间和UTC时间
- 关注别人CSDN博客的方法
- spring cloud-ribbon