Binary Log
The binlog records all changes that modify the database. It drives replication and is also used for point-in-time recovery.
The binlog records all changes that modify the database. It drives replication and is also used for point-in-time recovery.
-- 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
ROW-based binlog is safest for replication — it records exact row changes, not just the SQL statement.