*************************************
* About BINLOG *
*************************************
-- BINLOG is in a more effective format and contains all available information in the Update log in a transaction-safe manner.
-- BINLOG contains all statements that update data or have potentially updated data (for example, a delete statement that does not match any row. The statement is saved as an "Event" and describes data changes.
-- BINLOG also contains the execution time of each statement to update the database. It does not contain statements that do not modify any data. If you want to record all statements (for example, to identify problematic queries), you should use general query logs.
-- The main purpose of BINLOG is to make it possible to update the database during restoration, because BINLOG contains all updates made after backup.
-- BINLOG is also used to record all statements that will be sent to the slave server on the master replication server.
-- If BINLOG is enabled when the server is running, the performance is about 1% slower. However, the benefit of BINLOG is that it is used to recover and allow setting replication to exceed this small performance loss.
-- When the -- log-bin [= file_name] option is enabled, mysqld writes a log file containing all SQL commands for updating data. If the file_name value is not given, the default name is the host name followed by-bin. If the file name is provided but the path is not included, the file is written to the data directory. We recommend that you specify a file name. If you provide an extension (for example, -- log-bin = file_name.extension) in the log name, the extension is removed and ignored.
-- Mysqld adds a digital extension after each BINLOG name. This number is added every time you start the server or refresh the log. If the current log size reaches max_binlog_size, a new BINLOG is automatically created. If you are using a large transaction, the BINLOG will also exceed max_binlog_size: the transaction is completely written into a BINLOG and never written into different binlogs.
-- To know which BINLOG file is used, mysqld creates a BINLOG index file that contains the names of all BINLOG files used. By default, the file name is the same as that of the BINLOG file. The extension is '. Index '. You can use the -- log-bin-index [= file_name] Option to change the file name of the BINLOG index file. When mysqld is running, you should not manually edit the file; otherwise, mysqld will become messy.
-- The BINLOG format has some known restrictions, which may affect recovery from backup.
-- By default, BINLOG is not synchronized with the hard disk every time it is written. Therefore, if the operating system or machine (not just the MySQL server) crashes, the last statement in BINLOG may be lost. To prevent this situation, you can use the sync_binlog global variable (1 is the safest value, but also the slowest) To synchronize the BINLOG with the hard disk after each n BINLOG writes.
**************************************** ********
* How to manage MySQL BINLOG *
**************************************** ********
1. Add the following parameter to my. ini to specify the database to be updated to BINLOG: db_name. The database not specified here will not record BINLOG
-- BINLOG-do-DB = db_name
2. Add the following parameter to my. ini to specify the database to which the update to BINLOG is not saved: db_name
-- BINLOG-ignore-DB = db_name
3. If BINLOG has been generated, clear it using the SQL command line:
/*
* To clear logs, follow these steps:
* 1 use show slave status on each slave server to check which log it is reading.
* 2 Use show Master logs to obtain a series of logs on the master server.
* 3 determine the earliest log among all slave servers. This is the target log. If all slave servers are updated, this is the last log in the list.
* 4. Back up all logs to be deleted. (This step is optional, but is recommended .)
* 5 clear all logs, but not the target logs.
*
*/
/*
* Clear BINLOG
*
* To execute a reset, you must have the reload permission.
* The following command deletes all binlogs listed in the index file, resets the BINLOG index file to null, and creates a new BINLOG.
* (In earlier versions of MySQL, it is called flush master .)
*/
Reset master;
/*
* Clear the specified BINLOG
*
*/
Purge master logs to 'mysql-bin.010 ';
/*
* Clear the BINLOG before 06:06:06, January 6 ,.
*
* The date independent variable of before can be in 'yyyy-MM-DD hh: mm: ss' format. Both master and binary are synonyms.
*/
Purge master logs before '2017-06-06 06:06:06 ';
/*
* Clear the BINLOG 3 days ago
*
*/
Purge master logs before date_sub (now (), interval 3 day );