Methods of maintaining MySQL database log files

Source: Internet
Author: User

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".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.