Nasser Heidari

2010-03-30

Mysql Replication Useful Commands

Filed under: Miscellaneous — Nasser Heidari @ 11:51

SHOW BINLOG EVENTS

SHOW BINLOG EVENTS
[IN ‘log_name’] [FROM pos] [LIMIT [offset,] row_count]
e.g:

mysql> show binlog events in 'bin.000017' from 36383578 limit 50\G

Shows the events in the binary log.

—————————————————————————————-
show binary logs;
Lists the binary log files on the server.

—————————————————————————————-

PURGE BINARY LOGS TO 'bin.000015';
PURGE BINARY LOGS BEFORE '2010-03-01 00:00:00';
PURGE BINARY LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 7 DAY);

The PURGE BINARY LOGS statement deletes all the binary log files listed in the log index file prior to the specified log file name or date. BINARY and MASTER are synonyms. Deleted log files also are removed from the list recorded in the index file, so that the given log file becomes the first in the list.

—————————————————————————————-
Recovery from binary logs:

mysqlbinlog --stop-position="368312" /data/mysql/bin.000015 | mysql -u root -p
mysqlbinlog --start-position="368315" /data/mysql/bin.000015| mysql -u root -p

mysqlbinlog --stop-date="2010-03-01 19:00:00" /data/mysql/bin.000015 | mysql -u root -p
mysqlbinlog --start-date="2010-03-01 00:00:00" /data/mysql/bin.000015 | mysql -u root -p

mysqlbinlog /data/mysql/bin.000015 > /tmp/mysql_restore.sql

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: