How to turn on MySQL slow query log

Source: Internet
Author: User
Tags mysql client set time mysql slow query log

1,

Https://github.com/Meituan-Dianping/SQLAdvisor/blob/master/doc/QUICK_START.md

http://www.ttlsa.com/mysql/meituan-sql-optimization-tool-sqladvisor/

Enter the command in the MySQL client:

Show variables like '%quer% ';

The options for the red box callout are:

-slow_query_log whether to log slow queries. Use the value of the Long_query_time variable to determine "slow query".

-slow_query_log_file Slow log file path

-long_query_time Slow Log execution time (seconds), the log is not logged until the set time is exceeded

2, Linux:

Added under the [mysqld] option of the/ETC/MY.CNF configuration file:

Slow_query_log=true

Slow_query_log_file=/usr/local/mysql/slow_query_log.txt

Long_query_time=3

Windows:

Added under the [mysqld] option of the My.ini configuration file:

Slow_query_log=true

Slow_query_log_file=c:/slow_query_log.txt

Long_query_time=3

3, after restarting MySQL, you can find that the slow query log has been turned on

Enter the command check in the MySQL client:

Show variables like '%quer% ';

How to turn on MySQL slow query log

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.