In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article focuses on "how to manage mysql binary logs". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to manage mysql binary logs.
Use parameters to automatically clear binary logs
By default, MySQL does not remove old binary logs that are not running. The expire_logs_days parameter automatically removes binary logs. The default value of this parameter is 0, which means
The binary log is not automatically removed. Assigning a value greater than 0 to this parameter removes logs that are greater than this value, in days.
Manually clear the binary log
Clear specific files
Click (here) to collapse or open
Mysql > purge binary logs to 'mysql-bin-3306.000005'
Query OK, 0 rows affected (0.08 sec)
Clear a specific log or time
Click (here) to collapse or open
Mysql > purge binary logs before '2017-09-25 1215 30 purl 00'
Query OK, 0 rows affected (0.01 sec)
Physically delete binary log
Rm-rf mysql-bin-3306.000005
Click (here) to collapse or open
Mysql > show master logs
+-+ +
| | Log_name | File_size |
+-+ +
| | mysql-bin-3306.000005 | 0 | |
| | mysql-bin-3306.000006 | 604 |
| | mysql-bin-3306.000007 | 891 | |
| | mysql-bin-3306.000008 | 346 |
| | mysql-bin-3306.000009 | 35946018 | |
+-+ +
If a binary log is deleted directly from the file system, even if the file is no longer in the file system, MySQL will display a pointer in a file with 0 bytes. Later, when you use the purge command to delete the binary log again, you will have the following prompt:
Click (here) to collapse or open
Mysql > purge binary logs to 'mysql-bin-3306.000006'
Query OK, 0 rows affected, 1 warning (0.02 sec)
Mysql > show warings\ G
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'warings' at line 1
Mysql > show master logs
+-+ +
| | Log_name | File_size |
+-+ +
| | mysql-bin-3306.000006 | 604 |
| | mysql-bin-3306.000007 | 891 | |
| | mysql-bin-3306.000008 | 346 |
| | mysql-bin-3306.000009 | 35946018 | |
+-+ +
4 rows in set (0.00 sec)
At this point, I believe you have a deeper understanding of "how to manage mysql binary logs". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.