How to kill multiple MySQL Connections

1.To kill multiple connections use below command

SELECT CONCAT('kill ',id,';') AS command FROM `information_schema`.`PROCESSLIST` WHERE USER='root' or time > 200; 
#modify where clause as per your requirement
###output ###
"command"
"kill 4;"
"kill 2;"

2.Now copy output and execute them

kill 4;
kill 2;

3.or We can

select concat('KILL ',id,';') from information_schema.processlist where user='root' 
or time > 200 into outfile '/tmp/a.txt';
#modify where clause as per your requirement

4.Now execute

source /tmp/a.txt;
Advertisements
This entry was posted in Mysql. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s