Query the locked process information of MySQL in Linux.

Source: Internet
Author: User
Tags mysql query

Query the locked process information of MySQL in Linux.
1. Problem Description

When using the database, tables may be locked, causing timeout when other processes access the same table. Specifically, use the following command in MySQL:

SHOW PROCESSLIST
The result is


The Status column indicates the query Status of the statement. If the value is Locked, the query is Locked by other queries. Host indicates the Host information that sends the query statement. The locked query is performed on the TCP connection issued by port 38292 of Host 192.168.1.152. The information of the locked statement is provided in the Info column.

Based on this information, how can we find the information about the process where the locked SQL statement is located to help DEBUG?

2. Solution a. view the process PID based on the TCP port number. Method 1: lsof
Lsof-Pnl + M-i4 | grep 38292


Method 2: netstat
Netstat-anp | grep 38292

Run the preceding statement on the host 192.168.1.152, as shown in. The process PID corresponding to port 38292 obtained by the two methods is 11882.
B. view the process information based on the PID and run the following command on host 192.168.1.152 to view the process information.
Pss aux | grep 11882
As shown in, you can view basic information such as the commands started by the process.
Based on the above information, you can troubleshoot the MySQL query lock table and provide the required information for further debugging.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.