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