Today found/usr/local/mysql/var under a lot of mysql-bin.000001, mysql-bin.000002 files, Google's. This is the operation log of the database, such as update a table, or delete some data, even if the statement does not have matching data, this command will be stored in the log file, also includes the time of each statement execution, also recorded in. This has the following two purposes:
1: Data recovery
If your database is out of order and you have a previous backup, you can look at the log file to find out which command caused your database to go wrong and try to recover the loss.
2: Synchronizing data between master and slave servers
All operations on the primary server are recorded in the log, which can be performed from the server to ensure two synchronizations. There are two kinds of processing methods:
1: Only one MySQL server, then you can simply comment out this option is OK.
Vi/etc/my.cnf the inside of the Log-bin this line commented out, restart the MySQL service.
2: If your environment is a master-slave server, then you need to do the following.
A: On each subordinate server, use Show SLAVE status to check which log it is reading.
B: Use show master logs to get a series of logs on the primary server.
C: In all subordinate servers to determine the oldest log, this is the target log, if all the subordinate server is updated, is the last log on the list.
D: Clean up all the logs, but not the target log, since the server also synchronizes with it.
The cleanup log method is:
PURGE MASTER LOGS to ' mysql-bin.010 ';
Query OK, 0 rows affected (8.51 sec) mysql> OK, let's see how much space is in the MySQL folder? [Email protected] 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/OK, look, the entire MySQL directory occupies 163M size! OK, no problem, since the mysql-bin.0000x log file occupies such a large space, the significance of the existence is not particularly large, then we will not let it generate it.
[[email protected] var]# Find/-name my.cnf found the my.cnf is the MySQL configuration file, we will log-bin=mysql-bin this comment out.
# Replication Master Server (default)