How to kill all MySQL sleeping processes

PostJan 30th, 2012 | Comments (1)
If you need to kill all sleeping processes in MySQL, here's a quick 'n' easy PHP solution:

$result = mysql_query("SHOW processlist");
while ($myrow = mysql_fetch_assoc($result)) {
    if ($myrow['Command'] == "Sleep") {
        mysql_query("KILL {$myrow['Id']}");
    }
}

Comments

AndrewFeb 13, 2012
Where's the mysqli object oriented version? ;)

Post a comment

Name
URL
Email
Comment