Get the App
SLTechnology News&Howtos  ›  Database  › 

How to maintain database log files in MySQL

Shulou Source: shulou.com Published: 2022-05-31 21:03:14 09月11日 Update

MySQL how to maintain database log files, I believe that many inexperienced people are helpless about this, this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Because log files are important references for recovering 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 logging in new files. This article covers how to enable new log files, both update logs and regular logs. The method described here also applies to binary logs.

How to use the new update log

If you are using only one update log, you simply empty the log file, then move the old update log file to a backup, and enable the new update log.

You can force the server to enable the new update log in the following ways:

◆ admin flush-logs

You generally need to provide the database users used at the command line:

mysqladmin -u root -p flush-logs

◆ mysqladmin refresh

You generally need to provide the database users used at the command line:

mysqladmin -u root -p refresh

If you are using MySQL 3.21 or earlier, you must use mysqladmin refresh.

◆ SQL commands

FLUSH LOGS

◆ Restart server

The above methods all have such functions:

Close and reopen standard and update log files. If you specify an update log file without an extension, the extension of the new update log file will be increased by 1 relative to the previous file.

mysql>FLUSH LOGS;

How to use the new regular log

You can also force regular logs to be updated using the above method.

To prepare for a backup of regular logs, the steps can be a little more complicated:

$ cd mysql-data-directory$ mv mysql.log mysql.old$ mysqladmin flush-tables

Then make a backup and delete "mysql.old."

After reading the above, do you know how to maintain database log files in MySQL? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!

Tags: Logs files updates methods data databases backups general commands important content more servers users problems services complex helpless for this binary Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Tech Info macOS Linux Huawei