![MySQL] Output Slow Query Log](https://aws.darcy-it.com/wp-content/uploads/2021/02/2021-05-12_11h14_28.png)
environment
Version
# mysql --version mysql Ver 14.14 Distrib 5.7.33, for Linux (x86_64) using EditLine wrapper
setting (of a computer or file, etc.)
vim /etc/my.cnf.d/query_slow.cnf ----------------------------------------------------------- [mysqld] slow_query_log=1 long_query_time=1 log_queries_not_using_indexes=0 slow_query_log_file=/var/log/mysql_query_slow.log -----------------------------------------------------------
Setting items | Configuration details |
slow_, slow_, slow |
Output slow query log.
Default value is 0 (no output). |
long_ |
Output SQL that takes 1 second.
Specified in the range of0~360024365 seconds. Can be specified down to the μs unit by specifying a decimal point value. It is also possible to save all SQL issued by specifying 0 seconds. |
log_ |
Set index to record unused queries. |
slow_ |
Specify the output destination of the slow query log. |
Creating Logs
# touch /var/log/mysql_query_slow.log # chown mysql.mysql /var/log/mysql_query_slow.log # systemctl restart mysqld
Related Articles
MySQL] Configuration to reflect the contents under /etc/my.cnf.d (darcy-it.com)