- 查看正在使用的表
show open tables where In_use > 0;
- 查看当前用户正在运行的数据库进程
show processlist ;
- 当前运行的所有事务
select * from information_schema.INNODB_TRX;
- 当前出现的锁
select * from information_schema.INNODB_LOCKS;
- 锁等待的对应关系
select * from information_schema.INNODB_LOCK_WAITS;
- 未提交的事务
select t1.ID, t1.USER, t1.DB, t1.COMMAND, t1.INFO, t2.trx_started, t2.trx_state from information_schema.PROCESSLIST t1 inner join information_schema.INNODB_TRX t2 on t1.id = t2.trx_mysql_thread_id where DB = 'sakila';
- 批量删除事务表中的事务
select concat('kill', t1.ID, ';') from information_schema.PROCESSLIST t1 inner join information_schema.INNODB_TRX t2 on t1.id = t2.trx_mysql_thread_id where DB = 'sakila';