数据库卡死-一张表卡死其他表正常


前言
博主在使用使用大量定时器任务对数据库操作的时候,中间接到一个任务,需要直接对库里的字段进行修改,随性使用了一个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;



 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章