Tuesday, April 1, 2014

Mass killing of MySQL Sleep Connections

Every so often I run into situation when I need to kill a lot of connections on MySQL server – for example hundreds of instances of some bad query is running making server unusable. Many people have special scripts which can take the user, source host or query as a parameter and perform the action. There is also a way to do it just using MySQL with a few commands:

example.....

SELECT CONCAT('KILL ',id,';') FROM information_schema.processlist WHERE USER='root';