MySQL Forums
Forum List  »  MySQL Administrator

Re: mysql slow query log deletion
Posted by: Barry Galbraith
Date: September 10, 2009 09:03PM

From the reference manual
Section 5.2.5 Server Log Maintenance

A log flushing operation does the following:

If general query logging (--log) or slow query logging (--log-slow-queries) to a log file is enabled, the server closes and reopens the general query log file or slow query log file.

If binary logging (--log-bin) is used, the server closes the current log file and opens a new log file with the next sequence number.

If the server was given an error log file name with the --log-error option, it renames the error log with the suffix -old and creates a new empty error log file.

The server creates a new binary log file when you flush the logs. However, it just closes and reopens the general and slow query log files. To cause new files to be created on Unix, rename the current logs before flushing them. At flush time, the server will open new logs with the original names. For example, if the general and slow query logs are named mysql.log and mysql-slow.log, you can use a series of commands like this:

shell> cd mysql-data-directory
shell> mv mysql.log mysql.old
shell> mv mysql-slow.log mysql-slow.old
shell> mysqladmin flush-logs
At this point, you can make a backup of mysql.old and mysql-slow.log and then remove them from disk.

Before 5.0.17, you cannot rename a log file on Windows while the server has it open. You must stop the server and rename the file, and then restart the server to create a new log file. As of 5.0.17, this applies only to the error log. However, a stop and restart can be avoided by using FLUSH LOGS, which causes the server to rename the error log with an -old suffix and open a new error log.

Good Luck,

Options: ReplyQuote

Written By
September 10, 2009 12:30PM
Re: mysql slow query log deletion
September 10, 2009 09:03PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.