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:
- PURGE MASTER LOGS TO 'mysql-bin.010';
-
- 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.
- [Root @ jiucool var] #/usr/local/mysql/bin/mysql-u root-p
-
- Enter password: (Enter the password)
-
- Welcome to the MySQL monitor. Commands end with; or \ g.
-
- Your MySQL connection id is 264001
-
- Server version: 5.1.35-log Source distribution
-
- Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.
-
- Mysql> reset master; (clear log files)
-
- Query OK, 0 rows affected (8.51 sec)
-
- Mysql>
Now, let's check the space occupied by the mysql folder?
- [root@jiucool var]# du -h –max-depth=1 /usr/local/mysql/
-
- 37M /usr/local/mysql/var
-
- 70M /usr/local/mysql/mysql-test
-
- 15M /usr/local/mysql/lib
-
- 448K /usr/local/mysql/include
-
- 2.9M /usr/local/mysql/share
-
- 7.6M /usr/local/mysql/libexec
-
- 17M /usr/local/mysql/bin
-
- 11M /usr/local/mysql/docs
-
- 2.9M /usr/local/mysql/sql-bench
-
- 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.
- [root@jiucool var]# find / -name my.cnf
Find my. cnf, which is the mysql configuration file. Comment out log-bin = mysql-bin.
- # Replication Master Server (default)
-
- # binary logging is required for replication
-
- #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!