user984003
user984003

Reputation: 29597

MySQL recovery, include binlog position MASTER_LOG_POS

I run a MySQL DB dump like this:

mysqldump mydatabase -u root -p --single-transaction --events --routines --quick --master-data=2 --flush-logs --flush-privileges > mydump.sql

This creates a dump file, which contains the following line:

CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000008', MASTER_LOG_POS=120;

This tells me that any new changes are recorded starting in mysql-bin.000008

I can then, after loading my dump file, load the incremental files like this (assuming mysql-bin.000009 was also created at some point):

mysqlbinlog mysql-bin.000008 mysql-bin.000009 | mysql -u root -p mydatabase

But what about MASTER_LOG_POS = 120? Do I need to include that and, if so, how? My dump command included --flush-logs so it should have started a brand new file.

I'm reading the here https://dev.mysql.com/doc/refman/5.7/en/backup-policy.html and here https://dev.mysql.com/doc/refman/5.7/en/recovery-from-backups.html

Upvotes: 0

Views: 1520

Answers (1)

Bill Karwin
Bill Karwin

Reputation: 562881

https://dev.mysql.com/doc/refman/5.6/en/mysqlbinlog.html#option_mysqlbinlog_start-position says:

--start-position=N, -j N

Start reading the binary log at the first event having a position equal to or greater than N. This option applies to the first log file named on the command line.

This option is useful for point-in-time recovery.

Upvotes: 1

Related Questions