How to safely delete binlog logs under mysql

Source: Internet
Author: User

Recently, it was found that there are too many logs in the binlog directory of mysql, and the disk space is full, resulting in Website access failure.


-Rw ---- 1 mysql 1073742161 May 31 binlog.20.21

-Rw ---- 1 mysql 1073742892 May 31 binlog.20.22

-Rw ---- 1 mysql 1073741876 Jun 1 binlog.20.23

-Rw ---- 1 mysql 1073741892 Jun 1 binlog.20.24

-Rw ---- 1 mysql 1073742650 Jun 1 binlog.000025

-Rw ---- 1 mysql 1073742008 Jun 1 binlog.20.26

-Rw ---- 1 mysql 1073743194 Jun 1 binlog.20.27

-Rw ---- 1 mysql 1073743161 Jun 1 binlog.20.28

-Rw ---- 1 mysql 1073741891 Jun 1 binlog.20.29

-Rw ---- 1 mysql 1073742841 Jun 1 binlog.20.30

-Rw ---- 1 mysql 1073744077 Jun 1 binlog.000031

-Rw ---- 1 mysql 1073744098 Jun 1 binlog.20.32

-Rw ---- 1 mysql 1073743330 Jun 1 binlog.20.33

-Rw ---- 1 mysql 1073746020 Jun 14 binlog.000034

-Rw ---- 1 mysql 1073743436 Jun 15 binlog.000035

-Rw ---- 1 mysql 247808012 Jun 18 binlog.20.36

-Rw ---- 1 mysql 20455501 Jun 18 binlog.20.37

-Rw ---- 1 mysql 694690 Jun 18 binlog.20.38

-Rw ---- 1 mysql 4366694 Jun 18 binlog.20.39

-Rw ---- 1 mysql 192837775 Jun 21 binlog.000040

-Rw ---- 1 mysql 26720306 Jun 21 binlog.20.41

-Rw ---- 1 mysql 1073741956 Jun 21 binlog.20.42

-Rw ---- 1 mysql 1073742382 Jun 21 binlog.20.43

-Rw ---- 1 mysql 1073755643 Jun 21 binlog.20.44

-Rw ---- 1 mysql 1073745037 Jun 22 binlog.000045

-Rw ---- 1 mysql 1073745820 Jun 23 binlog.20.46

-Rw ---- 1 mysql 768790035 Jun 24 binlog.20.47

-Rw ---- 1 mysql 1073742672 Jun 24 binlog.20.48

-Rw ---- 1 mysql 1073751254 Jun 24 binlog.20.49

-Rw ---- 1 mysql 1073743150 Jun 24 binlog.000050

-Rw ---- 1 mysql 1073745450 Jun 24 binlog.20.51

-Rw ---- 1 mysql 1073742107 Jun 24 binlog.20.52

-Rw ---- 1 mysql 1073743107 Jun 24 binlog.42453

-Rw ---- 1 mysql 1073745069 Jun 25 binlog.20.54

-Rw ---- 1 mysql 1073757980 Jun 25 binlog.20.55

-Rw ---- 1 mysql 1073750646 Jun 25 binlog.20.56

-Rw ---- 1 mysql 1073749126 Jun 25 binlog.000057

-Rw ---- 1 mysql 332813390 Jun 25 binlog.000058

-Rw ---- 1 mysql 2106 Jun 25 binlog. index


The solution is as follows:

Method 1:

Mysql> show binary logs; view mysql bin-log logs. You can delete all logs except this log.

Mysql> purge binary logs to 'binlog. 100'; Delete mysql bin-log and delete binlog.000005, excluding binlog.000058)

Method 2:

Go to the database and check which binlog is currently in use. You can use rm-rf to delete other logs!


This article is from the "Linus_hai" blog, please be sure to keep this source http://linushai.blog.51cto.com/4976486/1229527

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.