前言
博主在使用使用大量定時器任務對數據庫操作的時候,中間接到一個任務,需要直接對庫裏的字段進行修改,隨性使用了一個alter table name drop column 命令結果卡住了。
卡住不要緊,我們可以使用命令來看看到底是哪個操作卡住了,然後將它kill掉
1、開始,命令查看,是哪臺服務器上運行了什麼命令
select id, db, user, host, command, time, state, info
from information_schema.processlist
where command != 'Sleep'
order by time desc ;
2、可以看到那個端口運行了命令和命令執行的開始時間,根據端口開始時間長的將它殺死
select * from information_schema.innodb_trx;
3、mysql 命令中直接執行即可殺死端口
kill 29832;
另附幾條常用SQL:
show processlist;
show full processlist;
select * from information_schema.innodb_locks;
select * from information_schema.innodb_lock_waits;
select id, db, user, host, command, time, state, info
from information_schema.processlist
order by time desc ;
附贈一條SQL,可以直接打印出kill語句,複製執行即可:
select concat('kill ', id, ';')
from information_schema.processlist
where command != 'Sleep'
and time > 100
order by time desc;