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 mysql clears logs

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

Share

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

This article mainly describes how mysql clear logs, the text is very detailed, has a certain reference value, interested friends must read!

In mysql, you can purge logs with the purge command, which purges specified data, using the syntax "purge binary logs to 'mysql-tb-bin.00005';."

Operating environment of this tutorial: Windows 10 system, mysql version 8.0.22, Dell G3 computer.

How do I clean my blog?

Open Mysql binary log and.log log, these log files are very large,. log has reached 25 G, mysql-bin.00000X log has also reached 5 G, first clean up the log files on the main server, I first clean up the binary file (mysql-bin.00000X), first check which files:

Use the command to view:

show binary logs;

Then go and see from the server which binary is in use,

show slave status\G;

We see mysql-tb-bin.000005 log file in use.

Go back to the main server and start cleaning the log, but you can't clean the mysql-tb-bin.000005 log file. Clean it with the command:

purge binary logs to 'mysql-tb-bin.000005';

This command is to clean up other binary logs except mysql-tb-bin.000005; after successful execution, check the binary log list: show binary logs;

Clean up successfully, but this manual cleaning is very dangerous, but also more complex, there is no automatic cleaning method? The answer is yes, add this configuration in my.ini: expire_logs_days=5 This configuration means that the log expiration days, more than 5 days of logs, mysql will automatically clean up the logs 5 days ago, so you don't have to worry about the log file getting bigger and bigger, when executing the command must be careful, to ensure that nothing is wrong before execution.

The above is "mysql how to clear the log" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

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