View SQL statements being executed by MySQL in the log

Source: Internet
Author: User

In project development, you always need to view the SQL statements executed in the background, and mysql database is no exception. Generally, you prefer to use showprocesslist, the types of SQL statements that can be analyzed and executed in the field interpretation of the output results are not suitable for general beginners. Therefore, viewing SQL statements through log files is the most direct method.

First, you must create a log file log.txt. For example, you can directly store the log file in the data directory of the mysql directory, and then add it to the mysql configuration file my. cnf.

Log =/var/log/mysql/mysqlProcess. log

In this way, all SQL statements executed by mysql can be recorded!

Log =/var/log/mysql/mysqlProcess. log

Add to [mysqld] Block

You need to manually create this file, and then chown mysql: mysql has the same permission as mysqld. log.

Recommended reading:

Create and modify MySQL view charts

MySQL view)

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.