Friday, January 31, 2014

Killing Long-Running MySQL Processes

Killing long running MySQL queries is easy. There is KILL command

where PROCESS_ID is an ID from SHOW PROCESSLIST command. I have created small PHP script to kill all long running processes using RegExp.

You can checkout it from my Github: https://github.com/klivan/MySQL-Process-Killer

Just change $host, $user and $password to access your MySQL server, and add regexp that matches your query.

Change $minExecutionTimeToKill to minimum number of seconds that query should be running before killing.

To run simply execute:

$ php ./kill.php

View on Github