Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to maintain database log files in MySQL

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report