fbpx
Recommended Services
Supported Scripts
x 1

The commented out examples in the default configuration file (https://97a481b0.rocketcdn.me/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

Please note: If you notice the mysql-slow.log file logging every query then remove the line "log-queries-not-using-indexes" from your /etc/my.cnf file and restart mysql. It should the load only the slow queries
Share this Post

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.