The original address: MySQL is slow sql hang, with shell script to quickly clear the growing slow SQL method MCHDBA
A novice DBA mistakenly deleted index,mysql is all over 10S slow sql,mysql service is hang, and slow SQL constantly in the increase, if manually in the MySQL interface kill, it is too late, this time, the shell must be shot, As the shell script below, you can refer to:
#It is used to kill processlist of MySQL sleep#!/bin/shwhile:d o n= ' mysqladmin processlist-uadmin-pxxxxx|grep-i SLE EP |wc-l ' date= ' date +%y%m%d\[%h:%m:%s] ' echo $n if ["$n"-gt] then - i in ' mysqladmin process List-uadmin-pxxxxxx|grep-i sleep |awk ' {print $} ' do mysqladmin-uadmin-pxxxxxx kill $i done Echo ' Sleep is too many I killed it ">>/tmp/sleep.log echo" $date: $n ">>/tmp/sleep.log fi Sleep 1done
Finally, quickly add the appropriate index!
"Reprint" MySQL is slow sql hang, with shell script to quickly clear the growing slow SQL method