AI智能
改变未来

mysql查看并解决表被锁情况


1,查看进程

使用mysql命令: show processlist;
如下所示:

mysql> show processlist;+------+-----------------+----------------------+-------------+---------+---------+------------------------+------------------+| Id   | User            | Host                 | db          | Command | Time    | State                  | Info             |+------+-----------------+----------------------+-------------+---------+---------+------------------------+------------------+|    4 | event_scheduler | localhost            | NULL        | Daemon  | 2322336 | Waiting on empty queue | NULL             || 4319 | fixass_dev      | localhost:60178      | fixass_dev  | Sleep   |       0 |                        | NULL             || 4421 | fixass_dev2     | 111.84.70.187:31191  | fixass_dev2 | Sleep   |      66 |                        | NULL             || 4422 | root            | localhost            | NULL        | Query   |       0 | starting               | show processlist |+------+-----------------+----------------------+-------------+---------+---------+------------------------+------------------+37 rows in set (0.00 sec)

如果State 这一列出现如下提示:

Waiting for table metadata lock

就使用kill命令:kill Id;
如: kill 4422; 表示杀死id为4422的进程。

2,如果仍然出现锁表现象
就查询如下sql:

select * from information_schema.innodb_trx;

找到对应的进程ID。再使用kill命令。

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » mysql查看并解决表被锁情况