All server logs require some maintenance. We will start with the FLUSH
statements, which can be used occasionally, to ensure that the last information is written to the files. Then, we will discuss how to rotate both the file- and table-based logs to the free space available on the disk.
After performing certain operations, or before performing a backup, you may want to flush the contents in the logs. Flushing a log means that its files are closed and reopened, and all the buffered information is written to the file during the process. For file-based logs, the FLUSH LOGS
statement can be used. To flush all logs, simply run the following command:
FLUSH LOGS;
The following flavors are available to selectively flush only one log:
FLUSH ERROR LOGS; -- error log FLUSH GENERAL LOGS; -- general query log FLUSH SLOW LOGS; -- slow query log FLUSH BINARY LOGS; -- binary log FLUSH ENGINE LOGS; -- storage engines logs FLUSH RELAY LOGS; -- replication slaves...