Check whether the table is locked:
Execute directly on the mysql command line: show engine innodb status\G.
Check the sql statements that caused the deadlock, analyze the index situation, and then optimize the sql.
Then show processlist to check the sql statements that caused the deadlock to take a long time.
show status like ‘%lock%.
Check the table lock status and end the deadlock steps:
1. Check the table lock status
show OPEN TABLES where In_use > 0; This statement records the current lock table status
2. Query process
show processlist Query table locked process
Query the corresponding process kill id
3. Analyze the SQL of the locked table
Analyze the corresponding SQL, add indexes to the table, add indexes to common fields, and add indexes to table related fields
View Things being locked:
SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS.
View things waiting for locks:
SELECT * FROM INFORMATION_SCHEMA. INNODB_LOCK_WAITS.
The above is the detailed content of Mysql checks whether the table is locked. For more information, please follow other related articles on the PHP Chinese website!