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 also be stored in the log file, including the time of execution of each statement, will also be recorded.
This has the following two main purposes:
1: Data recovery
If you have a database problem, and you have a backup before, then you can look at the log file, find out which command caused your database problem, find a way to recover the loss.
2: Synchronizing data between master and slave servers
All operations on the primary server are in the logging log, which can be done from the server to ensure two synchronizations.
The processing method is divided into two situations:
1: Only a MySQL server, then you can simply comment out this option on the line.
Vi/etc/my.cnf the inside of the Log-bin this line comment out, restart the MySQL service.
2: If your environment is the master and slave server, then you need to do the following operations.
A: On each subordinate 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 primary server.
C: In all subordinate servers to determine the earliest 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 because it is also synchronized from the server.
The cleanup log method is:
PURGE MASTER LOGS to ' mysql-bin.010′;
PURGE MASTER LOGS before ' 2008-12-19 21:00:00′;
If you are sure that you have synchronized from the server and are the same as the primary server, you can delete the files directly from the Reset master.
[Root@localhost bin]# Mysql-uroot-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; Or\g.
Your MySQL Connection ID is 5476
Server Version:5.1.30-log MySQL Community Server (GPL)
Type ' help, ' or ' \h ' for help. Type ' \c ' to clear the buffer.
root@ (none) 09:49:12>show master logs;
+ ———— + ——— –+
| Log_name | File_size |
+ ———— + ——— –+
| bin.000060 | 107372679 |
| bin.000061 | 107372692 |
| bin.000062 | 107372833 |
| bin.000063 | 107372706 |
| bin.000064 | 107372817 |
| bin.000065 | 107372590 |
| bin.000066 | 107372601 |
| bin.000067 | 107372754 |
| bin.000068 | 107372800 |
| bin.000069 | 64215845 |
+ ———— + ——— –+
Rows in Set (0.00 sec)
Mysql> purge master logs to ' mysql-bin.000067′;
Query OK, 0 rows affected (9.39 sec)
Mysql> show master logs;
+ ———— + ——— –+
| bin.000067 | 107372754 |
| bin.000068 | 107372800 |
| bin.000069 | 64215845 |
+ ———— + ——— –+
Add:
2. Turn off binary log
Edit file:
Vi/etc/my.cnf
Note the following code:
#log-bin=mysql-bi (www.111cn.net) n
#binlog_format =mixed
3, restart the MySQL server
Service MySQL Restart