Get the App
SLTechnology News&Howtos  ›  Database  › 

How to check whether the table is locked in mysql

Shulou Source: shulou.com Published: 2022-06-01 18:06:47 09月30日 Update

This article mainly tells you briefly how to check whether the table is locked in mysql. You can check the relevant professional terms on the Internet or find some related books to supplement them. We will not dabble here, so let's go straight to the topic. I hope this article on how to check whether the table is locked in mysql can bring you some practical help.

Check to see if the table is locked:

Execute directly on the mysql command line: show engine innodb status\ G.

Look at the sql statement that caused the deadlock, analyze the index, and then optimize sql.

Then show processlist, look at the sql statement that caused the deadlock to take a long time.

Show status like'% lock%.

Check the locked status of the table and the steps to end the deadlock:

1. Check the locked status of the table

Show OPEN TABLES where In_use > 0; this statement records the current lock table status

two。 Query process

Show processlist lookup table locked process

Query the corresponding process kill id

3. Analyze the SQL of the lock table

Analyze the corresponding SQL, index the table, index the common fields, and index the fields associated with the table.

Look at what is being locked:

SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS.

Look at what is waiting for the lock:

SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS.

Mysql how to check whether the table is locked first to tell you here, for other related issues you want to know can continue to pay attention to our industry information. Our section will capture some industry news and professional knowledge to share with you every day.

Tags: Status statement process Gasso deadlock analysis query specialty thing field industry expertise subject book content command actual commonly used situation news Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Docker Redmi MariaDB OPPO Reno