Tuesday, May 12, 2009

Mysql transaction log restoration

almost all the documents you can find on the Net are telling you to use mysqlbinlog to read the binary logs and pipe the output to mysql client, but this method simply will fail on windows system if the database contains binary data such as blob and binvarchar, due to escaping and piping problem in mysqlbinlog utility. the mysql utility simply can not read the file or output stream created by mysqlbinlog.

here's a workaround though, we can tell mysql to use --execute "source xx" option to parse the log files from mysqlbinlog.

E.g.
C:\> mysqlbinlog binary_log_file --result-file=/tmp/bin.sql
C:\> mysql --user=root --execute "source /tmp/bin.sql"

ref 1: http://bugs.mysql.com/bug.php?id=33048
ref 2: http://www.linuxtopia.org/online_books/database_guides/mysql_5.1_database_reference_guide/windows-vs-unix.html

No comments: