執行如下SQL,查看當前事務:
select t.trx_mysql_thread_id, t.trx_started, t.trx_state, t.trx_tables_in_use, t.trx_tables_locked, t.trx_rows_locked, timestampdiff(second, t.trx_started, now()) as trx_run_seconds, concat(e.timer_wait/1000000000000, 's') as timer_wait_seconds from information_schema.innodb_trx t join performance_schema.threads c on c.processlist_id=t.trx_mysql_thread_id join performance_schema.events_statements_current e on e.thread_id=c.thread_id
返回是trx_mysql_thread_id就是線程ID,通過kill命令可以終止線程。