第一种
#1.查询是否锁表
MySQL> show OPEN TABLES where In_use > 0; |
#2.查询进程(如果您有SUPER权限,您可以看到所有线程。否则,您只能看到您自己的线程)
mysql> show full processlist; |
#3.杀死进程id(就是上面命令的id列)
[linux-command] kill id; |
第二种
#1.查看正在锁的事务
mysql> select * from information_schema.innodb_trx; |
#2.杀死进程id(就是上面命令的trx_mysql_thread_id列)
mysql> show processlist; [linux-command] kill 420821 |
#3.查找执行事务的客户端请求的SQL线程
mysql> select * from information_schema.processlist where id=76613; |
#4.通过SQL线程,找到应用程序的IP地址以及端口192.168.10.1:23452
[linux-command].NETstat -nlatp |grep 23452 [linux-command] ps -eaf|grep 12059 |
其它关于查看死锁的命令
#1:查看当前的事务
select * from information_schema.innodb_trx; |
#2:查看当前锁定的事务
select * from information_schema.innodb_locks; |
#3:查看当前等锁的事务
select * from information_schema.innodb_lock_waits; |
#4:查看锁表情况
select r.trx_id as waiting_trx_id, r.trx_mysql_thread_id as waiting_thread, r.trx_query as waiting_query, b.trx_id as blocking_trx_id, b.trx_mysql_thread_id as blocking_thread, b.trx_query as blocking_query, (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(b.trx_started)) as block_time from information_schema.innodb_lock_waits w inner join information_schema.innodb_trx b on b.trx_id = w.blocking_trx_id inner join information_schema.innodb_trx r on r.trx_id = w.requesting_trx_id; |