原因: (1)连接后没有关闭(2)死锁(3)程序重开的连接数太多等
解决 :
(1)连接后如果不用及时关闭,
(2)手动关闭不用连接
mysql> show processlist; +----+------+-----------+--------------------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------+--------------------+---------+------+-------+------------------+ | 37 | root | localhost | information_schema | Query | 0 | NULL | show processlist | | 38 | root | localhost | NULL | Sleep | 559 | | NULL | +----+------+-----------+--------------------+---------+------+-------+------------------+ mysql> kill 40; 1 row in set (0.00 sec) mysql> use information_schema mysql> select id from processlist; +----+ | id | +----+ | 40 | +----+ 1 row in set (0.00 sec) mysql> select concat('kill ',id,';') from information_schema.processlist where user='root' into outfile '/export/yoon.txt'; Query OK, 1 row affected (0.09 sec) [root@db01 export]# more yoon.txt kill 40; 批量删除会话: mysql> source /export/yoon.txt
(3) 配置mysql最大连接数
这 种方式说来很简单,只要修改MySQL配置文件my.ini 或 my.cnf的参数max_connections,将其改为max_connections=1000,然后重启MySQL即可。
时间: 2024-10-28 13:29:27