Enabling the slow query log

From Shrubbery

Jump to: navigation, search


Enablilng the slow query log on Linux:

  1. Edit /etc/my.cnf, add:
    # log-slow-queries=/var/log/mysqld-slow-queries.log
    log-queries-not-using-indexes
  2. Create the log file for the mysql user:
    # touch /var/log/mysqld-slow-queries.log
    # chown mysql:mysql /var/log/mysqld-slow-queries.log
  3. Restart MySQL:
    # service mysqld restart

Take queries out of the slow query log and analyze them using EXPLAIN

See:

Personal tools