The Binary Log
- The binary log contains all statements that update data or potentially could have updated it.
- Statements are stored in the form of "events" that describe the modifications.
- It also contains information about how long each statement took that updated data.
- It is not used for statements such as
SELECT or SHOW that do not modify data.
- The primary purpose of the binary log is to be able to update databases during a restore operation as fully as possible, because it contains all updates done after a backup was made.
- The binary log is also used on master replication servers as a record of the statements to be sent to slave servers.
- If using the binary log for replication do not remove binary logs until their contents have been processed by all slaves.
- To enable the binary log, start
mysqld with the --log-bin[=name].
- If no name value is given,
mysqld uses the hostname followed by -bin and writes the file in the data directory.
- Running the server with the binary log enabled makes performance about 1% slower.
- The benefits of the binary log for restore operations and setting up replication outweigh this minor performance decrement.
What is the maximum size of binary logs?
© 2007 John Michael Pierobon
Notes