Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

3 Answers 3

up vote 3 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

share|improve this answer

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.