CleverCode研究了一下,怎么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
时间: 2024-10-01 13:02:53