查询出锁定的表
SELECT concat('KILL ',id,';') FROM information_schema.processlist WHERE user='root';
SELECT concat('KILL ',id,';') FROM information_schema.processlist WHERE command='Locked' and user='root';
SELECT concat('KILL ',id,';') FROM information_schema.processlist WHERE command='Locked' and user='root' and db='test';
拼装kill命令后输入到kill.sql, source 将从kill.sql读取sql命令并执行。
SELECT concat('KILL ',id,';') FROM information_schema.processlist WHERE user='root' INTO OUTFILE '/tmp/kill.sql'; source /tmp/kill.sql;
mysqladmin -uroot -p processlist | grep Sleep |awk '{if (length($2) > 1) print "Kill "$2}'|xargs mysqladmin -uroot kill
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。