MySQL 5.6 – How to log slow queries (Linux)

In MySQL 5.6, they introduced a different way for 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 5.6

  1. Login to your MySQL host
  2. Open the my.cnf file in your favorite text editor:vi /etc/my.cnf
  3. Add the following properties:

    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
  4. Reload the MySQL configuration (will not cause an interruption)
    service mysql reload
See also  Create a compressed MySQL database dump/backup (Linux)

2 thoughts on “MySQL 5.6 – How to log slow queries (Linux)”

Leave a Comment