当前位置: 移动技术网 > IT编程>数据库>Mysql > MySql如何解除正在死锁的状态?

MySql如何解除正在死锁的状态?

2018年12月19日  | 移动技术网IT编程  | 我要评论

解除正在死锁的状态有两种方法:

第一种:

首先查询是否锁表:show open tables where in_use > 0;查询进程,保证拥有超级管理员权限:show processlist;

杀死进程id(就是上面命令的id列):kill id;

第二种:

查看下在锁的事务 :select * from information_schema.innodb_trx;

杀死进程id(就是上面命令的trx_mysql_thread_id列):kill 线程id

其它关于查看死锁的命令:

1:查看当前的事务

select * from information_schema.innodb_trx;

2:查看当前锁定的事务

select * from information_schema.innodb_locks;

3:查看当前等锁的事务

select * from information_schema.innodb_lock_waits;

批量杀死进程sql:

select concat( 'kill ', id, ';' ) from information_schema.processlist where user = 'root' into outfile '/tmp/kill.txt';

source /tmp/kill.txt;

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网