In MySQL 5.6, they introduced a different way of logging slow queries compared to previous versions. This article will show you how to quickly, and correctly enable the slow query log which is extremely useful for debugging application performance issues.
Enable Slow Query Log in MySQL
- Login to your MySQL host
- Open the my.cnf file in your favorite text editor:
vi /etc/my.cnf
- Add the following properties:
long_query_time=1
slow_query_log=1
slow_query_log_file="/var/log/mysql/log-slow-queries.log"
long_query_time – Defines the minimum threshold for the “slow query” designation. 1 means log all queries that take more than 1s to executeslow_query_log – Value of 1 means enable. 0 means disableslow_query_log_file – Log file path. This path generally be at the same location as mysql-error.log - Reload the MySQL configuration (will not cause an interruption)
service mysql reload
# service mysqld reload
I’m pretty sure there is no way to reload the configuration file without restarting mysqld.