(转)批量 kill mysql 中运行时间长的sql

时间:2024-12-31 21:05:26
mysql> show full processlist;
+--------+------+---------------------+------+---------+------+----------+-----------------------+
| Id | User | Host | db | Command | Time | State | Info |
+--------+------+---------------------+------+---------+------+----------+-----------------------+
| 559818 | root | 10.253.124.77:46824 | NULL | Sleep | 52 | | NULL | select concat('kill ',Id,';') from information_schema.processlist where db='szdj' and Command='Sleep' order by time desc limit 20;
mysql> select concat('kill ',Id,';') from information_schema.processlist where db='szdj'  and Command='Sleep' order by time desc limit 5;
+------------------------+
| concat('kill ',Id,';') |
+------------------------+
| kill 593948; |
| kill 594523; |
| kill 594588; |
| kill 593550; |
| kill 594449; |
+------------------------+ 鼠标 Alt 选中目标:
kill 593948;
kill 594523;
kill 594588;
kill 593550;
kill 594449;

在sql命令行执行选中目标,完成操作。