Occasionally, you find yourself in the need to kill problematic
connections to the database.
Usually if it's only one or two connections, you can use the
combination of "SHOW PROCESSLIST" command to identify the
problematic connection ID, and run a "KILL ID" command.
What do you do if you need to kill 10 connections? Or 56? I wouldn't want to type in all those kill commands, it's just dirty work. What we need is a more neat manner to perform those kills. Mass kill, if you wish.
Alternative way: use the INFORMATION_SCHEMA's PROCESSLIST table, to construct the kill statements semi-automatically.
SELECT CONCAT('kill ',id,';') AS kill_list
FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE command='Sleep';
This select will return something like this (when using the
command line client):
…[Read more]