代码改变世界

MySQL批量杀死某个用户建立的连接

2022-04-09 14:56  abce  阅读(158)  评论(0编辑  收藏  举报
select concat('kill ', id, ';') as run_this
  from information_schema.processlist
 where user = 'root'
 into outfile '/tmp/kill_process.txt';

#info列表示执行特定sql的连接

select concat('kill ', id, ';') as run_this
  from information_schema.processlist
 where user = 'root'
   and info = 'select * from processlist'
   into outfile '/tmp/kill_process.txt';