How to kill all MySQL sleeping processes
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']}");
}
}
Where's the mysqli object oriented version? ;)
Leave a Comment