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.