How do I enable log_slow_queries on MySQL 5.1? Im running redhat.

link|improve this question
feedback

3 Answers

up vote 0 down vote accepted

As mentioned by RedMumba, this is correct..

log_slow_queries=/var/log/mysql/log-slow-queries.log

http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_log_slow_queries

you might also want to consider how "slow" the queries are by seconds that you want to log using

long_query_time = 1   # Log anything over 1 second..

http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_long_query_time

link|improve this answer
feedback

You'll want to edit /etc/my.cnf and add:

log_slow_queries=/var/log/mysql/log-slow-queries.log

Where the value is equal to the log file to store the slow queries.

Andrew

link|improve this answer
feedback

You may also want to define what a slow query time is, eg: long_query_time = 5

Both this and log_slow_queries should be in the [mysqld] section.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown