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

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

1 Answer 1

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:

http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password

share|improve this answer

Your Answer

 
discard

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.