What’s the Difference Between MySQL Redo Log and Binlog? (Interview Insight)
The article explains that MySQL redo log operates at the InnoDB engine layer to ensure transaction durability and crash recovery, while binlog works at the server layer to record logical changes for replication, archiving, and point‑in‑time recovery, highlighting their distinct layers, purposes, content, and write mechanisms.
1. Different Levels
redo logis the InnoDB storage‑engine‑level log and only affects InnoDB. It primarily supports transaction commit and crash‑recovery mechanisms. binlog is the MySQL server‑level log and does not depend on a specific storage engine. Any data change executed by the server is typically recorded in binlog.
UPDATE user SET age = 20 WHERE id = 1;2. Different Functions
redo log’s core function is to guarantee transaction durability (the D in ACID). It follows Write‑Ahead Logging: when an InnoDB data page has not yet been flushed to disk, the modification is first written to the redo log, allowing the system to redo committed transactions after a crash. binlog ’s core function is data archiving, master‑slave replication, and point‑in‑time recovery. It records the logical SQL change process, making it easy for replicas to replay the master’s operations or to recover data after accidental deletion.
Write Ahead Logging (WAL)3. Different Recorded Content
redo logrecords physical changes, focusing on page‑level modifications. Because it deals with low‑level data, the log size is small and writes are fast. binlog records logical changes, usually the executed SQL statements or row events. This logical representation aligns with business semantics and is convenient for replay in different environments.
4. Different Write Timing and Persistence
redo logis written in a circular buffer (ring buffer) with a fixed space; when the buffer is full it overwrites old entries. During a transaction, InnoDB first writes modifications to the redo‑log buffer and then flushes it according to a configured policy.
redolog:循环写(Ring Buffer) binlogis appended sequentially to log files that grow until a size limit, after which a new file is created. It is usually flushed at transaction commit, preserving a global change record.
写 redo log(prepare 状态)2. 写 binlog 3. redo log 提交(commit)Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Architect Chen
Sharing over a decade of architecture experience from Baidu, Alibaba, and Tencent.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
