SyntaxStudy
Sign Up
MySQL Intermediate 4 min read

Binary Log (binlog)

Binary Log

The binlog records all changes that modify the database. It drives replication and is also used for point-in-time recovery.

Example
-- Enable binlog (my.cnf)
-- log_bin = /var/log/mysql/mysql-bin.log
-- server_id = 1
-- binlog_format = ROW  (recommended: row-based logging)
-- Show binlog status
SHOW MASTER STATUS\G
SHOW BINARY LOGS;
-- View binlog events
SHOW BINLOG EVENTS IN "mysql-bin.000001" LIMIT 20;
-- mysqlbinlog (command line)
-- mysqlbinlog mysql-bin.000001 | mysql -u root
Pro Tip

ROW-based binlog is safest for replication — it records exact row changes, not just the SQL statement.