mysql 批量kill多个进程

数据库管理员 2月前 ⋅ 138 阅读

查看进程

show PROCESSLIST;
+--------+--------+---------------------+------+---------+------+-
| Id     | User   | Host | db | Command | Time | State  | Info        
+--------+--------+---------------------+-------+------+------+---
132185 | root | 192.168.160.2:42366 |db_test| Sleep | 872 |
132186 | root | 192.168.160.2:42368 |db_test| Sleep | 866 |
132187 | root | 192.168.160.2:42398 |db_test| Sleep | 849 |

kill单个进程 kill id

kill 132187

多个进程要kill当然要批量查询

批量查询执行超过6秒以上的语句

select concat('kill ', id,';') from information_schema.processlist where time>6000;

批量查询锁表的语句

select concat('kill ', id,';') from information_schema.processlist where state like '%Locked%';

最后将查询的结果复制运行就kill掉了;这两个批量kill查询感觉非常特别方便,值得收藏!


全部评论: 0

    我有话说: