show processlist中kill锁表语句与慢sql

1 单个kill

mysql> show processlist;

mysql > kill 251;


#批量kill

1)查找Lockd语句

mysql -uroot -p123456 -h 192.1.20.101 -e "show processlist" | grep -i 'Locked' > locked_log.txt


2)组合kill

for line in `cat locked_log.txt | awk '{print $1}'`

do 

   echo "kill $line;" >> kill_thread_id.sql

done


3)执行

mysql>source kill_thread_id.sql