Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have Investigated enabling MySQL query logging. At some point, soon, it would be nice to enable this on my companies production server so that if there is ever a question about queries run against the database, we can see them.

I have found: Add the following line to /etc/my.cnf: log=/var/log/mysql_query.log and restart the MySQL server. I could also profile slow queries: log-slow-queries = /var/log/mysql_slow_queries.log long_query_time = 1.

I have not yet found any documentation detailing log file size capping to ensure that the file does not continue to grow past a certain point. Is anyone aware of such a thing?

share|improve this question
up vote 1 down vote accepted

You can use logrotate on linux to help with this. There are many howtos that show you how to do this. Essentially, make sure logrotate is in your crontab, I use the daily one on busy machines.

Then just create /etc/logrotate.d/mysql accordingly and you're off to the races!

Here's a great howto:

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.