Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have restored a dump into MySQL. I also have a binary log, which I want to partially restore, let's say from position 10 - 2500.

How can I do that?

share|improve this question
add comment

migrated from stackoverflow.com Aug 22 '12 at 12:35

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 1 down vote accepted

Use the mysqlbinlog utility

mysqlbinlog --help gives the following:

-j, --start-position=#
                  Start reading the binlog at position N. Applies to the
                  first binlog passed on the command line.
--stop-position=#   Stop reading the binlog at position N. Applies to the
                  last binlog passed on the command line.

Suppose your binary log is called mysql-bin.012345. You would do the following for positions 10 - 2500 to attach it to a mysqldump called MySQLData.sql:

Either

mysqlbinlog --start-position=10 --stop-position=2500 mysql-bin.012345 > SQLFromBinLog.sql
cat SQLFromBinLog.sql >> MySQLData.sql

or append directly with

mysqlbinlog --start-position=10 --stop-position=2500 mysql-bin.012345 >> MySQLData.sql

Give it a Try !!!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.