Check whether MySQL has enabled viewing slow SQL log files
(1) Check whether slow SQL logs are enabled
Mysql> show variables like 'Log _ slow_queries ';
+ ------------------ + ------- +
| Variable_name | value |
+ ------------------ + ------- +
| Log_slow_queries | on |
+ ------------------ + ------- +
1 row in SET (0.00 Sec)
(2) Check the seconds in which the SQL statement will be executed and recorded in the log file.
Mysql> show variables like 'long _ query_time ';
+ ----------------- + ------- +
| Variable_name | value |
+ ----------------- + ------- +
| Long_query_time | 1 |
+ ----------------- + ------- +
1 row in SET (0.00 Sec)
Here value = 1, indicating 1 second
2. configure My. INI file (the file name in inux is my. CNF), find the [mysqld] section, and add the log configuration, as shown in the following example:
[mysqld]
log =" C:/temp/MySQL. log "
log_slow _ Queries = "C:/temp/mysql_slow.log"
long_query_time = 1
log indicates the log file storage directory.
log_slow_queries indicates the SQL log directory with a long execution time;
long_query_time indicates the execution time, in seconds.
in Linux, these configuration items should already exist, but have been commented out. You can remove the annotations. However, it is okay to add configuration items directly.