The binary log is a set of files that contain information about data modifications made to a MySQL server instance.
The log consists of a set of binary log files, plus an index file.
Each log file contains a 4-byte magic number, followed by a set of events that describe data modifications:
The magic number bytes are 0xfe 0x62 0x69 0x6e = 0xfe 'b''i''n' (this is the
Each event contains header bytes followed by data bytes:
The header bytes provide information about the type of event, when it was generated, by which server, and so forth.
The data bytes provide information specific to the type of event, such as a particular data modification.
The first event is a descriptor event that describes the format version of the file (the format used to write events in the file).
The remaining events are interpreted according to the version.
The final event is a log-rotation event that specifies the next binary log filename.
The index file is a text file that lists the current binary log files.
The details about event structure have changed over time, which gives rise to different versions of the binary log format. Currently, there are three binary log format versions, described in #Binary Log Versions.
The log files are sequentially numbered using a
.NNNNNN suffix. The index file has a suffix
.index. All files share a common basename.
The default binary log file-naming basename is
"HOSTNAME-bin". With the default basename,
the binary log has files with names like this:
... HOSTNAME-bin.0000101 HOSTNAME-bin.0000102 HOSTNAME-bin.0000103 ... HOSTNAME-bin.index
Relay log file naming is similar to that of the binary log files. The default relay log file-naming basename is "HOSTNAME-relay". With the default basename, the relay log has files with names like this:
... HOSTNAME-relay.0000101 HOSTNAME-relay.0000102 HOSTNAME-relay.0000103 ... HOSTNAME-relay.index