Thursday, September 25, 2008

Flushing the log-slow-queries log file

One of the things that I have seen a lot of questions on is how to "flush" the slow query log. I think most people expect when you perform a mysql>Flush Logs that it will create a new log file. This is true for the Binary logs but not the slow query and general logs.

The action that mysql takes when the mysql>Flush Logs command is given closes and then reopens the slow query and general logs.

To start a new log you will want to rename the current log file then perform a mysql>Flush Logs. MySQL will create a new log file with whatever you have set as the log-slow-queries= slow_queries
On windows you would roughly perform:
c:\>cd mysql-data-directory
d:\db\data>ren slow_queries slow-queries-old
d:\db\data>mysql -u user -pPassword
mysql>flush logs;
mysql>exit;
The same goes for the general log file. The only assumption made in this article is that you are actually already logging slow queries via your my.ini config option of log-slow-queries= slow_queries

No comments: