The source and solution of mysql-bin.000001 file are introduced in detail.

Source: Internet
Author: User

InMySQL databaseMedium,Mysql-bin.000001,Mysql-bin.000002Such files are database operation logs, such as updating a table or deleting some data. Even if the statement does not match the data, this command is stored in the log file, the execution time of each statement is also recorded.

There are two main purposes to do this:

1. Data Recovery

If there is a problem with your database, and you have had a backup before, you can check the log file to find out which command causes a problem with your database and find a way to recover the loss.

2: synchronize data between master and slave servers

All operations on the master server are recorded in the log. The slave server can follow the log to ensure two synchronization.

There are two solutions:

1: There is only one mysql server. You can simply comment out this option.

Vi/etc/my. cnf comment out the log-bin line and restart the mysql service.

2: If your environment is a master-slave server, you need to perform the following operations.

A: On each SLAVE server, use show slave status to check which log it is reading.

B: Use SHOW MASTER LOGS to obtain a series of LOGS on the MASTER server.

C: Identify the earliest log among all slave servers. This is the target log. If all slave servers are updated, it is the last log in the list.

D: clear all the logs, but not the target logs, because the slave server needs to synchronize with it.

The log cleanup method is as follows:

 
 
  1. PURGE MASTER LOGS TO 'mysql-bin.010';  
  2.  
  3. PURGE MASTER LOGS BEFORE '2008-12-19 21:00:00'; 

If you are sure that the slave server has been synchronized, just like the MASTER server, you can directly RESET the MASTER to delete these files.

==============================================

I found that I had 10 Gb of server space, and 5 GB was left in a few days. I uploaded only a few hundred MB of files. What took up such a large space? Today, we have time to thoroughly check:

Check that the web root directory in the preceding directory is stored in/home. All the files are less than 300 MB, and the server occupies nearly 5 GB of space, finally, I learned by step-by-step query that the folder occupied a lot of space resources:

It turns out that the var directory in the mysql folder occupies the largest space. What is the content in it? Let's take a look:

Found so many mysql-bin.0000X files, what is this? It turns out this is the mysql operation log file. I only have dozens of M databases, and the operation log is 3 GB in size.

How do I delete mysql-bin.0000X log files?

Red indicates the input command.

 
 
  1. [Root @ jiucool var] #/usr/local/mysql/bin/mysql-u root-p
  2.  
  3. Enter password: (Enter the password)
  4.  
  5. Welcome to the MySQL monitor. Commands end with; or \ g.
  6.  
  7. Your MySQL connection id is 264001
  8.  
  9. Server version: 5.1.35-log Source distribution
  10.  
  11. Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
  12.  
  13. Mysql> reset master; (clear log files)
  14.  
  15. Query OK, 0 rows affected (8.51 sec)
  16.  
  17. Mysql>

Now, let's check the space occupied by the mysql folder?

 
 
  1. [root@jiucool var]# du -h –max-depth=1 /usr/local/mysql/  
  2.  
  3. 37M     /usr/local/mysql/var  
  4.  
  5. 70M     /usr/local/mysql/mysql-test  
  6.  
  7. 15M     /usr/local/mysql/lib  
  8.  
  9. 448K    /usr/local/mysql/include  
  10.  
  11. 2.9M    /usr/local/mysql/share  
  12.  
  13. 7.6M    /usr/local/mysql/libexec  
  14.  
  15. 17M     /usr/local/mysql/bin  
  16.  
  17. 11M     /usr/local/mysql/docs  
  18.  
  19. 2.9M    /usr/local/mysql/sql-bench  
  20.  
  21. 163M    /usr/local/mysql/ 

Okay. Check that the entire mysql directory occupies 16 m! OK, no problem, since the mysql-bin.0000X Log File occupies such a large space, the significance of existence is not particularly large, so we won't let it generate it.

 
 
  1. [root@jiucool var]# find / -name my.cnf 

Find my. cnf, which is the mysql configuration file. Comment out log-bin = mysql-bin.

 
 
  1. # Replication Master Server (default)  
  2.  
  3. # binary logging is required for replication  
  4.  
  5. #log-bin=mysql-bin 

Restart MySQL. Everything is OK! About MySQL database mysql-bin.000001 file source and processing method is introduced here, I hope this introduction can bring you some gains, thank you for browsing!

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.