某个数据库表锁死 导致操作阻塞

1.先进入库中,再查看当前数据库锁表的情况;

SELECT trx_mysql_thread_id FROM information_schema.INNODB_TRX;

2.杀掉查询结果中锁表的trx_mysql_thread_id
kill trx_mysql_thread_id

mysql> use logonuser;
Database changed

mysql> SELECT trx_mysql_thread_id FROM information_schema.INNODB_TRX;      
+---------------------+
| trx_mysql_thread_id |
+---------------------+
|                6973 |
|                6951 |
|                6943 |
+---------------------+
3 rows in set (0.00 sec)

mysql> kill 6973;
Query OK, 0 rows affected (0.00 sec)

mysql> kill 6951;
Query OK, 0 rows affected (0.00 sec)

mysql> kill 6943;
Query OK, 0 rows affected (0.00 sec)


 

3.show processlist 分析数据库进程;
kill id 杀进程;

mysql> show processlist;
+------+-----------------+-----------+-----------+---------+----------+------------------------+------------------+
| Id   | User            | Host      | db        | Command | Time     | State                  | Info             |
+------+-----------------+-----------+-----------+---------+----------+------------------------+------------------+
|    1 | event_scheduler | localhost | NULL      | Daemon  | 29030001 | Waiting on empty queue | NULL             |
| 7060 | root            | localhost | logonuser | Query   |        0 | init                   | show processlist |
+------+-----------------+-----------+-----------+---------+----------+------------------------+------------------+
2 rows in set (0.00 sec)

 

Logo

更多推荐