MySQL binary log

The binary log contains all statements that update data or potentially could have updated it.

Corresponding lines in my.cnf:

[...]
# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

# WARNING: Using expire_logs_days without bin_log crashes the server!
expire_logs_days        = 10
max_binlog_size         = 256M

[...]

Dealing with binary logs

mysql> show master logs;
+------------------+------------+
| Log_name         | File_size  |
+------------------+------------+
| mysql-bin.000010 | 1073741886 |
| mysql-bin.000011 | 1073741886 |
| mysql-bin.000012 |    2684333 |
| mysql-bin.000013 |        117 |
| mysql-bin.000014 |        117 |
| mysql-bin.000015 |        394 |
| mysql-bin.000016 |         98 |
+------------------+------------+
6 rows in set (0.00 sec)

Remove all logs before 'mysql-bin.000011'

mysql> purge binary logs to 'mysql-bin.000011';
Query OK, 0 rows affected (0.60 sec)

Result:

mysql> show master logs;
+------------------+------------+
| Log_name         | File_size  |
+------------------+------------+
| mysql-bin.000011 | 1073741886 |
| mysql-bin.000012 |    2684333 |
| mysql-bin.000013 |        117 |
| mysql-bin.000014 |        117 |
| mysql-bin.000015 |        394 |
| mysql-bin.000016 |         98 |
+------------------+------------+
6 rows in set (0.00 sec)

Remove all binary logs older than given date:

mysql -e "PURGE BINARY LOGS BEFORE '2009-07-01 0:00:00';
mysql/binary-log.txt · Last modified: 2009/07/21 16:14 by tb
CC Attribution-Noncommercial-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0