The showprocesslist command is commonly used to view mysql statements. However, it makes sense to query statements that take a long time. It is really hard to execute statements that can be executed at once. so we can only start from the mysql history. to achieve this, we need to modify etcmy. cnf file. in my. [m in cnf
To view mysql statements, we usually use the show processlist command. However, this command makes sense for statements with a long query time, the statement that can be executed at once cannot be used quickly. so we can only start from the mysql history. to achieve this, we need to modify/etc/my. cnf file. in my. [m in cnf
To view mysql statements, we usually use the show processlist command. However, this command makes sense for statements with a long query time, the statement that can be executed at once cannot be used quickly.
So we can only start from the mysql history. To achieve this goal, we need to modify the/etc/my. cnf file.
In my. insert log =/etc/tmp/mysql under [mysqld] (which may be invalid elsewhere) in cnf. log (the log address can be defined by yourself, but it should not be in the home, otherwise it may not be displayed, mainly with write permission ). restart the database and run the service mysqld restart command. this log records all the execution statements, so when the database is busy, this log may become very large and should not be viewed.
You can use the tail-f/etc/tmp/mysql. log command to continuously observe and execute the statement. You can also download the file and take a look at it.
========================================================== =
In addition, there is a slow query history, which is also in the my. cnf file. The configuration statement is
log-slow-queries=/var/lib/mysql/slowquery.log long_query_time=5 log-queries-not-using-indexes
Here, log-slow-queries is the address of the slow query history, and long_query_time is limited to more than X seconds before it can be added to the history, log-queries-not-using-indexes limits query statements that do not use indexes.
This log can be enabled for a long time because there are not many record statements.