Introduction
The binary log contains a record of all changes to the database, both data and structure. The binary log is not used for statements such as SELECT
or SHOW
that do not modify data. Running a server with binary logging enabled has a slight performance effect. The binary log is crash-safe. Only complete events or transactions are logged or read back.
Why should you use binary log?
- Replication: You stream the changes made to a server to another server using binary logs. The slave acts as a mirror copy and can be used to distribute the load. The server that accepts the writes is referred to as a master and the mirror copy server is referred to as a slave.
- Point-in-time recovery:Â Suppose you take a backup at 00:00 on Sunday and your database crashed at 8:00 on Sunday. Using backup, you can recover till 00:00 Sunday. Using binary logs you can reply to them, to recover till 08:00.