一 干掉不顺眼的
too many connection临时解决方案
查看连接,看看都是谁在捣乱:
mysql>show processlist;
结果如下:
查出那些建立但是无效的连接(视情况加条件)
mysql>select concat(‘KILL ‘,id,’;’) from information_schema.processlist where command=‘Sleep’ and db=‘IWantKill’;
结果如下
复制上面的查询结果出来,类似:
mysql>KILL 1001;
mysql>KILL 2001;
mysql>KILL 3003;
mysql>KILL 4004;
回车执行,杀死他们
二 修改最大连接数
mysql>show variables like “max_connections”; – 现在的最大连接数
mysql>set GLOBAL max_connections=1000; – 比刚刚查出来的更大
三 让他们早死早超生
mysql>show global variables like ‘wait_timeout’; – 看看原来是长时间
mysql>set global wait_timeout=300; – 连接最大空闲时长
或者
mysql>set global interactive_timeout=500;
关于interactive_timeout和wait_timeout更详细的说明,参考
MySQL中interactive_timeout和wait_timeout的区别