Slow query logs are composed of some SQL statements. When the query time exceeds the value of long_query_time, the slow query log is generated. The minimum value of longquerytime is 1 s and the default value is 1 s.
Slow query logs are composed of some SQL statements. When the query time exceeds the value of long_query_time, the slow query log is generated. The minimum value of longquerytime is 1 s and the default value is 1 s.
Slow query logs are composed of some SQL statements. When the query time exceeds the value of long_query_time, the slow query log is generated. The minimum value of longquerytime is 1 s and the default value is 10 s.
Check whether MySQL slow query is Enabled:
Mysql> show variables like '% slow % '; + --------------------- + bytes + | Variable_name | Value | + --------------------- + bytes + | slow_launch_time | 2 | slow_query_log | OFF | slow_query_log_file | E: \ Program Files \ mysql-5.6.10-winx64 \ data \ lzjun-slow.log | + --------------------- + -------------------------------------------------------- + 3 rows in set (0.00 sec)
By default, the slowquerylog of MySQL is OFF. The following methods are enabled:
When MySQL is started:
Mysqld -- slow_query_log = [{0 | 1}] # MySQL5.5 or a later versionIf you do not specify a value or 1, 0 indicates that mysqld -- slowquerylogfile = filename indicates where the log file is saved. If you specify a value, it is saved in the homename-slow.log file that stores the data directory by default.
Mysqld -- log-slow-queries [= file_name] # MySQL5.1 and earlier versions
Set MySQL after startup
Set global slow_query_log = [1 | 0 | ON | OFF] set global slow_query_log_file = [file_name]
Configuration in my. ini
Slow_query_log = 1slow_query_log_file =/var/log/mysql_slow.log
Generally, the value of longquerytime should not be too large. The default value is 10 seconds, which is usually 2-5 seconds. Of course, slow query logs may affect MySQL performance. For the master-slave structure, open a dedicated server to monitor slow queries.
This article permanently updates the link address: