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


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



 

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值