There are two ways to view the mysql process
1. Enter mysql/bin directory and enter mysqladmin processlist;
2. Start mysql and enter show processlist;
If you have SUPER permission, you can see all threads. Otherwise, you can only see the threads initiated by you (this means that the current corresponding MySQL account running the thread).
mysql> show processlist; +-------+-----------+---------------------+----------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +-------+-----------+---------------------+----------+---------+------+-------+------------------+ | 19161 | test_user | 171.8.216.253:63583 | tbkttest | Sleep | 685 | | NULL | | 19164 | test_user | 171.8.216.253:63677 | tbkttest | Sleep | 297 | | NULL | | 19165 | root | localhost | tbkttest | Query | 0 | NULL | show processlist | | 19166 | root | localhost | NULL | Sleep | 36 | | NULL | +-------+-----------+---------------------+----------+---------+------+-------+------------------+ 4 rows in set (0.00 sec)
Let’s briefly talk about the meaning and purpose of each column.
The first column id, needless to say, is an identifier, which is very useful when you want to kill a statement.
The second column, the user column, displays the previous user. If you are not root, this command will only display the sql statements within your authority.
The third column, the host column, shows which IP and which port this statement was sent from. Can be used to track the user who posted the problematic statement.
The fourth column, the db column, shows which database this process is currently connected to.
The fifth column, the command column, displays the executed command of the current connection, usually sleep, query, and connect.
The sixth column is the time column, the duration of this state, the unit is seconds.
The seventh column, the state column, displays the status of the sql statement using the current connection. It is a very important column. There will be descriptions of all states later. Please note that state is just a certain state in the execution of the statement, a The sql statement, which has been queried as an example, may need to go through copying to tmp table, Sorting result, Sending data and other states before it can be completed.
The eighth column, the info column, displays the sql statement. Because the length is limited, long sql statements are not fully displayed, but it is an important basis for judging problem statements.
There are descriptions of all states in the mysql manual. The link is as follows: http://dev.mysql.com/doc/refman/5.0/en/general-thread-states.html
kill Dead process
kill id
.
The above is the detailed content of How to check mysql process. For more information, please follow other related articles on the PHP Chinese website!