Have you forgotten the mysql history?

Source: Internet
Author: User
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.

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.