Home  >  Article  >  Database  >  How to use binlog in mysql

How to use binlog in mysql

王林
王林forward
2023-05-26 17:10:061463browse

1. Used for master-slave replication. In the master-slave structure, binlog is sent from the master to the slave as an operation record, and the logs received by the slave server from the master are stored in the relaylog.

2. Used for data backup. After the database backup file is generated, the binlog saves the detailed information after the database backup so that the next backup can start from the backup point.

Example

# at 154
 
#170708 9:24:02 server id 12345 end_log_pos 219 CRC32 0x30763ffe Anonymous_GTID last_committed=0 sequence_number=1
 
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
 
# at 219
 
#170708 9:24:02 server id 12345 end_log_pos 313 CRC32 0x4d0140b3 Query thread_id=5 exec_time=0 error_code=0
 
SET TIMESTAMP=1499477042/*!*/;
 
SET @@session.pseudo_thread_id=5/*!*/;
 
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
 
SET @@session.sql_mode=1436549152/*!*/;
 
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
 
/*!\C utf8 *//*!*/;
 
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=8/*!*/;
 
SET @@session.lc_time_names=0/*!*/;
 
SET @@session.collation_database=DEFAULT/*!*/;
 
create database test
 
/*!*/;
 
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
 
DELIMITER ;
 
# End of log file
 
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
 
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

The above is the detailed content of How to use binlog in mysql. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete