How do I kill all the processes in Mysql "show processlist"?

TIMEX picture TIMEX · Dec 14, 2009 · Viewed 388.2k times · Source

Because I see a lot of processes there, and the "time" column shows big values for all of them.

Answer

Angelin Nadar picture Angelin Nadar · Mar 30, 2012

Mass killing operation saves time. Do it in MySql itself:

Run these commands

mysql> select concat('KILL ',id,';') from information_schema.processlist
where user='root' and time > 200 into outfile '/tmp/a.txt';

mysql> source /tmp/a.txt;

Reference

---------edit------------

if you do not want to store in file, store in a variable

Just run in your command prompt

> out1=$(mysql -B test -uroot -proot --disable-column-names  -e "select concat('KILL ',id,';') from information_schema.processlist where user='root' and time > 200;")

> out2= $(mysql -B test -uroot -proot --disable-column-names  -e "$out1")