Check MySQL Locks: Essential Commands

You can use the following command to check the locking situation in MySQL:

  1. View the tables currently being locked.
SHOW OPEN TABLES WHERE In_use > 0;
  1. View the rows currently locked.
SHOW ENGINE INNODB STATUS;

Next, search for “The latest deadlock information” in the output results, where the most recent deadlock information will be displayed, including the locked rows.

  1. Check the current status of lock waits:
SHOW PROCESSLIST;

Next, search for processes with the status “Waiting for table lock” or “Waiting for lock”, as these processes indicate a situation where a lock is being waited for.

I hope this helps you!

bannerAds