MySQL 5.6 - Enable Slow Query Logging

The commented out examples in the default configuration file (/etc/mysql/my.cnf) that comes with my MySQL 5.6 when installed through the Ubuntu PPA is incorrect. This tutorial will show you the settings you need to make in order to enable slow query logging.

# This tells mysql that you do want to use slow query logging.
slow_query_log=1

# Define where the log file should be
slow_query_log_file = /var/log/mysql/slow_queries.log

# Set this to the number of seconds a query must take to be considered "slow"
long_query_time = 1

# Also, if you want to log all queries that don't use indexes:
log-queries-not-using-indexes

After making any changes to the my.cnf file, don't forget to restart the service in order for them to take effect:

sudo service mysql restart

No comments:

Post a Comment