How to investigate root cause of MySQL dead lock

Try these useful commands:

1. list all transactions in progress

mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX\G

Output:

Normally, the output should be empty.

Kill locked process

mysql> kill {trx_mysql_thread_id}

2. list all running processes

mysql> show processlist;

Output:

Kill the locked process

mysql> kill {id}

3. check whether there are locked tables

mysql> show OPEN TABLES where In_use > 0;

Output:

Normally, the output should be empty.

Hope these helpful commands will help you recover your locked MySQL. Good luck!