• 欢迎访问显哥博客,本网站纯属学习技术,绝无商业用途,欢迎小伙伴们共同学习!研究技术!QQ:52249909 加我QQ
  • 世界75亿人,这么小的概率,能认识你,是我一生的幸运,不妨加个QQ接触一下:52249909 加我QQ

清除MySQL主从复制 mysql-bin.0000*日志文件【显哥出品,必为精品】

MySQL lixian 4年前 (2021-02-03) 613342次浏览 1091个评论 扫描二维码

MySQL bin-log 作用

1.数据恢复:如果你的数据库出问题了,而你之前有过备份,那么可以看日志文件,找出是哪个命令导致你的数据库出问题了,想办法挽回损失。
2.主从服务器之间同步数据:主服务器上所有的操作都在记录日志中,从服务器可以根据该日志来进行,以确保两个同步。

3.在什么时间会删除过期日志?
每次进行 LOG flush的时会自动删除过期的日志,那么什么时间才能触发log flush,手册上的解释为:
重启 MySQL
bin-log 文件大小达到参数 max_binlog_size 限制;
手工执行清理命令

自动清理方法1:(修改配置文件和在mysql内设置参数可无需重启服务)

vim my.cnf
expire_logs_days = 7 // 表示日志保留7天,超过7天则设置为过期的
 
# mysql -u root -p > show binary logs; > show variables like '%log%'; > set global expire_logs_days = 7;

手动清理方法2:(推荐)

如果没有主从复制,可以通过下面的命令重置数据库日志,清除之前的日志文件:

reset master;

但是如果存在复制关系,应当通过 PURGE 的名来清理 bin-log 日志,语法如下:

# mysql -u root -p
> purge master logs to 'mysql-bin.010’; //清除mysql-bin.010日志
> purge master logs before '2016-02-28 13:00:00'; //清除2016-02-28 13:00:00前的日志
> purge master logs before date_sub(now(), interval 3 day); //清除3天前的bin日志

注意,不要轻易手动去删除binlog,会导致binlog.index和真实存在的binlog不匹配,而导致expire_logs_day失效


本站博主 , 版权所有丨如未注明 , 均为原创
转载请注明原文链接:清除MySQL主从复制 mysql-bin.0000*日志文件【显哥出品,必为精品】
喜欢 (5)

您必须 登录 才能发表评论!

(1091)个小伙伴在吐槽
  1. 匿名2023-05-26 21:24
  2. Hello, I like your site very much, thank you very much.
  3. Hey guys, I'm trying to sell my house fast in Colorado and I was wondering if anyone had any tips or suggestions on how to do it quickly and efficiently? I've already tried listing it on some popular real estate websites, but I haven't had much luck yet. I'm considering selling my house for cash, but I'm not sure if that's the right choice. Any advice you have would be greatly appreciated. Thanks in advance!
    匿名2023-05-25 23:29
  4. Wouw Good Content, bravoo
    Metin2 EP2023-05-24 17:40
  5. Numeroloji Eğitimi Numeroloji Okült bir dal olup, evrenin sayısal bir kurgu içerdiğini, evrendeki hiçbir şeyin rastlantıya dayanmadığını, her şeyin sayısal bir düzen içinde meydana geldiğini varsayar ve sayılarla ilgili çeşitli analitik ve sentetik çalışmalarla, evrendeki ve olaylardaki gizli yasa ve ilkeleri keşfetmeyi amaçlar.
  6. Numeroloji Master Eğitimi Numeroloji evrendeki her harf ve sayının bir anlamının var olduğunu ve bunların birer gezegenle ilişkilendirilmesini yorumlar.
  7. türk ifşa one of the monst important turkish video series, and this is only one site can service it to all the world. so if u want to wathc it just keep going to follow us.
  8. Great content, thank you!!
    Portbet2023-05-23 21:27
  9. Title: Exceptional Service and Quality Backlinks from Backlink Hut Rating: 5* (5/5) I recently had the pleasure of using Backlink Hut's services, and I must say that I am thoroughly impressed. As an online business owner, I understand the importance of high-quality backlinks for improving search engine rankings and driving organic traffic to my website. Backlink Hut not only exceeded my expectations but also offered their services completely free of charge. From the very beginning, the team at Backlink Hut demonstrated their professionalism and commitment to customer satisfaction. The process of obtaining the backlinks was incredibly simple. All I had to do was provide my website URL, and they took care of the rest. Within a short period, they generated a comprehensive report detailing the backlinks they had created, which they promptly shared with me via both WhatsApp and email. The level of transparency and communication was truly outstanding. The quality of the backlinks provided by Backlink Hut is exceptional. Each backlink is from a reputable website, relevant to my niche, and contains valuable content. The team at Backlink Hut clearly understands the importance of high domain authority and relevance when it comes to backlinking. These backlinks have already started to improve my website's visibility in search engine results, leading to a noticeable increase in organic traffic. Moreover, I was particularly impressed by the attention to detail and the personalized approach they adopted throughout the process. They took the time to understand my business and tailor the backlinks accordingly. This level of customization sets Backlink Hut apart from other service providers in the market. In addition to their excellent service and high-quality backlinks, the fact that Backlink Hut offers their services for free is truly remarkable. It demonstrates their commitment to helping website owners succeed without imposing excessive costs. This is a rare find in the industry, and I am immensely grateful for their generosity. Overall, I wholeheartedly recommend Backlink Hut to anyone seeking high-quality backlinks. Their exceptional service, attention to detail, and personalized approach make them stand out from the competition. Whether you're a small business owner or a seasoned entrepreneur, Backlink Hut is the go-to destination for improving your website's search engine rankings and driving organic traffic. Thank you, Backlink Hut, for providing such an outstanding service for free. Disclaimer: This review is based on my personal experience with Backlink Hut, and I have not received any incentives or compensation for writing it. Thanks, Vikas
    匿名2023-05-23 16:35
  10. Welcome to Liquidation Pallets Near Me, your premier destination for high-quality pallets for sale! If you're on the lookout for incredible deals and a wide variety of products, you've come to the right place. Our website is dedicated to connecting savvy buyers like you with top-notch pallets sourced from reputable liquidation sources. Step into a world of possibilities as you browse through our extensive collection of pallets, each filled with a treasure trove of products waiting to be discovered. From electronics and appliances to clothing, accessories, and beyond, our diverse range of pallets ensures there's something for everyone. We understand that quality matters, which is why we meticulously inspect every pallet to ensure it meets our high standards. Rest assured that the products you'll find on our website are in excellent condition, ready to be utilized for personal use or to boost your business's inventory. Our user-friendly interface makes it effortless to explore our inventory, with categories and
    匿名2023-05-23 11:06
  11. Smm panel olarak kesintisiz hizmet vermekteyiz. Smm takipçi türkiyede ki en ucuz smm takipçi ana sağlayıcısıdır.
    smm panel2023-05-23 08:59
  12. Wouw, amazing!
  13. quality content thanks
  14. Trix - официальный сайт - Трикс играть онлайн раздача каждый день
  15. quality and beautiful content
  16. Интернет-магазин пряжи в Москве klubok.club - различные виды пряжи.
    匿名2023-05-21 21:14
  17. Trix - официальный сайт - Трикс играть онлайн раздача каждый день
  18. antalya web tasarım caglarbodrumlu.com
  19. Network Marketing Eğitimi<a href “https://myeduco.com/egitim/network-marketing-egitimi/” Network Marketing Eğitimi <| MyEduco Network Marketing Eğitimi Network Marketing Endüstrisi, yeni yüzyılın modern anlayış yapısıyla geliştirilmiş ve üretici ile tüketiciyi doğrudan buluşturan ve bunu e ticaret sisteminin alt yapısını kullanarak hayata geçiren etkili ve yeni nesil pazarlama modelidir. Network Marketing Eğitimi<a href “https://myeduco.com/egitim/network-marketing-egitimi/” Network Marketing Eğitimi <| MyEduco
  20. Nlp Master Practitioner Eğitimi<a href “https://myeduco.com/egitim/nlp-master-practitioner-egitimi/” Nlp Master Practitioner Eğitimi <| MyEduco Nlp Master Practitioner Eğitimi Nlp uygulayıcı eğitiminin üzerine yeni bilgi ve tekniklerin eklenerek tüm bilgilerin özümsenmesi ve beceri ile davranış boyutuna aktarılmasıdır. Bu eğitimde NLP teknikleri arasında geçiş yapabilmeyi, sorun tespiti, problemlerin çözüm yollarını, teknikleri kombine etmeyi ve bütünü gözden kaçırmadan sorun çözmeyi öğrenirler. Nlp Master Practitioner Eğitimi<a href “https://myeduco.com/egitim/nlp-master-practitioner-egitimi/” Nlp Master Practitioner Eğitimi <| MyEduco
1484950515255