MySQL] Output Slow Query Log

 

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 query_ (query) log=1 Output slow query log.

Default value is 0 (no output).

long_ query_ time=1 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_ queries_ not_ using_ indexes=0 Set index to record unused queries.
slow_ query_ log_ file=/var/log/mysql_query_slow.log 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)

おすすめの記事