Formatting code for MysqlBinlog
{{parent page="MySQL"}}
===Messing with binlogs===
==Show binlog positions in a log file==
%%
mysqlbinlog <log file> | grep log_pos
%%
==See if a log file is corrupted==
%%
mysqlbinlog <log file> > /dev/null
%%
==Create dump file from binlog==
%%
mysqlbinlog --start-date="2009-02-20 8:00:00" --stop-date="2009-02-21 8:00:00" \
/var/log/mysql/bin.000001 > /tmp/mysql_restore.sql
mysqlbinlog --stop-position="12345" /var/log/mysql/bin.000001 > /tmp/restore.sql
mysqlbinlog --start-position="12345" /var/log/mysql/bin.000001 > /tmp/restore.sql
%%
===Messing with binlogs===
==Show binlog positions in a log file==
%%
mysqlbinlog <log file> | grep log_pos
%%
==See if a log file is corrupted==
%%
mysqlbinlog <log file> > /dev/null
%%
==Create dump file from binlog==
%%
mysqlbinlog --start-date="2009-02-20 8:00:00" --stop-date="2009-02-21 8:00:00" \
/var/log/mysql/bin.000001 > /tmp/mysql_restore.sql
mysqlbinlog --stop-position="12345" /var/log/mysql/bin.000001 > /tmp/restore.sql
mysqlbinlog --start-position="12345" /var/log/mysql/bin.000001 > /tmp/restore.sql
%%