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.


Source - How to Kill All MySQL Sleeping Processes

Materialize

The Real-Time Data Platform for Developers

Buy me a coffeeBuy me a coffee