Because log files are important references for recovering database data, the maintenance of log files is also of great significance. When MySQL is used with log files, you sometimes want to delete/back up old log files and tell MySQL to start recording in a new file. This article covers how to enable new log files, including update logs and regular logs. The method described here also applies to binary logs.
How to use the new update log
If you use only one update log, you only need to clear the log file, then move the old update log file to a backup, and then enable the new update log.
You can force the server to enable a new update log in the following ways:
Mysqladmin Flush-logs
You typically need to provide a database user to use at the command line:
Mysqladmin–u root–p Flush-logs
Mysqladmin Refresh
You typically need to provide a database user to use at the command line:
Mysqladmin–u root–p Refresh
If you are using a MySQL 3.21 or earlier version, you must use Mysqladmin refresh.
SQL command
FLUSH LOGS
Reboot the server
All of the above methods have this functionality:
Closes and then opens the standard and update record files. If you specify an update record file without an extension, the extension number of the new update record file will be added to the previous file by 1.
Mysql>flush LOGS;
How to use the new regular log
You can also force updates to the regular log by using the above method.
To prepare to back up a regular log, the steps may be more complex:
$ cd mysql-data-directory$ mv Mysql.log mysql.old$ mysqladmin flush-tables
Then make a backup and delete "Mysql.old".