[MySQL] enables slow query logs

Source: Internet
Author: User

Although the operation is simple, because I didn't notice the MySQL permission to read and write files at the beginning, I found that although the configuration file my. CNF has enabled slow query, but the log file is not actually created; open MySQL error. log, prompting cocould
Not use 'slowquery. log '.

After changing the permission, you can finally print the slow query log. To avoid repeating the same mistakes, follow these steps to enable slow query logs:
(1) Modify/etc/MySQL/My. CNF: Add the following two lines of code after [mysqld]: in this way, slowquery is recorded when the query takes more than 3 seconds. log.
(2) ensure that MySQL has read and write permissions on the slowquery. Log File and its path. Because/var/log is originally the path where error. log is located, MySQL has the read and write permissions. Therefore, MySQL will automatically create a log file when the log file does not exist. If it is another path, you can use chown to modify the attributes of the file, and use chmod to modify the read and write permissions of the file.
(3) for analysis of slow query logs, MySQL mysqldumpslow is usually enough. For details, refer to http://www.ccvita.com/410.html. Another slow query and analysis tool, mysqlsla, is also good, with complete functions and easy-to-use parameter settings. For more information, see http://my.oschina.net/alexwu/blog/71058.

Related Article

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.