MySQL Enable slow log query

Source: Internet
Author: User

Query time-out: Long_query_time
Start slow scan log: Log_slow_queries={yes|no}
Start the slow scan log: Slow_query_log
Log record file: Slow_query_log_file [= file_name]
MySQL if the Slow_query_log=on option is enabled, queries that execute longer than Long_query_time are logged (the time at which the table is locked is not counted as the execution time). If the file_name value is not given by the log record file, the default is the hostname and the suffix is-slow.log. If a filename is given, but not an absolute pathname, the file is written to the data directory.

Mysql>show global variables like '%slow_query_log% ';+---------------------+-----------------------------------+| variable_name | Value |+---------------------+-----------------------------------+| Slow_query_log | OFF | | Slow_query_log_file | /data/mysql/iz28cmq5qeaz-slow.log |+---------------------+-----------------------------------+2 rows in set (0.03 Sec
Slow queries are not enabled by default and are recommended for server tuning.
Mysql>set global slow_query_log=on;Query OK, 0 rows affected (0.10 sec) mysql>show global variables like '%slow_query_log% ';+---------------------+-----------------------------------+| variable_name | Value |+---------------------+-----------------------------------+| Slow_query_log | On | | Slow_query_log_file | /data/mysql/iz28cmq5qeaz-slow.log |+---------------------+-----------------------------------+2 rows in Set (0.00 Sec
The default for a long time is 10 seconds, which is more than the slow query. Mysql>show global variables like ' long_query_time ';+-----------------+-----------+| variable_name | Value |+-----------------+-----------+| Long_query_time | 10.000000 |+-----------------+-----------+1 row in Set (0.00 sec)

MySQL Enable slow log query

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.