View MySQL threads

Source: Internet
Author: User

The output result of the processlist command shows which threads are running. This command can be used to identify problematic query statements.

1. Enter mysqladmin processlist In the MySQL/bin directory;

2. Start MySQL and enter show processlist (kill ID of a thread is disabled ;);

If you have the super permission, you can see all the threads. Otherwise, you can only see the self-initiated threads (this refers to the thread currently running in the corresponding MySQL account ).

The data format is as follows (only three are intercepted ):

Mysql> show processlist;

+ ----- + ------------- + -------------------- + ------- + --------- + ------- + ---------------------------------- + ----------

| ID | user | host | dB | command | time | state | info

+ ----- + ------------- + -------------------- + ------- + --------- + ------- + ---------------------------------- + ----------

| 207 | root | 192.168.0.20: 51718 | mytest | sleep | 5 | null

| 208 | root | 192.168.0.20: 51719 | mytest | sleep | 5 | null

| 220 | root | 192.168.0.20: 51731 | mytest | query | 84 | locked |

Select bookname, culture, value, type from book where id = 001

Let's briefly describe the meaning and purpose of each column. The first column, ID, needless to say, is an identifier. It is useful when you want to kill a statement. The user column displays the user before the ticket. If it is not the root user, this command only displays the SQL statements within your permission range. Host column, indicating the port from which the statement is sent. Well, it can be used to track users with problematic statements. DB column to show which process is currently connectedDatabase. Command column, showing the commands executed by the current connection, which is generally sleep, query, and connect ). Time column, the duration of this state, in seconds. The State column displays the status of the SQL statement that uses the current connection. It is an important column and will be described in the future. Note that the State is only a certain State in the statement execution, for an SQL statement that has been queried as an example, it may need to pass through the copying to TMP table, sorting result, sending data and other statuses to complete the SQL statement. The Info column displays this SQL statement because the length is limited, therefore, long SQL statements are not displayed completely, but an important basis for determining a problematic statement.

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.