How to Kill All MySQL Sleeping Processes

How to Kill All MySQL Sleeping Processes

 


Having a lot of MySQL sleeping processes can cause a huge spike in your CPU load.

Here is a simple one line command which would kill all of the current sleeping MySQL processes:

for i in `mysql -e "show processlist" | awk '/Sleep/ {print $1}'` ; do mysql -e "KILL $i;"; done

Hope that it helps.


 

Coffee For Me
Recent Posts
Proxies Demystified
Proxies Demystified
2019-11-05 09:31:05