Applying binary logs without adding to the binary log
Feb 25, 2010 / By Sheeri Cabral
Applying binary logs to a MySQL instance is not particularly difficult, using the
mysqlbinlog command line utility:
$> mysqlbinlog mysql-bin.000003 > 03.sql $> mysql < 03.sql
Turning off binary logging for a session is not difficult, from the MySQL commandline, if you authenticate as a user with the
mysql> SET SESSION sql_log_bin=0;
However, sometimes you want to apply binary logs to a MySQL instance, without having those changes applied to the binary logs themselves. One option is to restart the server binary logging disabled, and after the load is finished, restart the server with binary logging re-enabled. This is not always possible nor desirable, so there’s a better way, that works in at least versions 4.1 and up:
The mysqlbinlog utility has the
--disable-log-bin option. All the option does is add the
SET SESSION sql_log_bin=0; statement to the beginning of the output, but it is certainly much better than restarting the server twice!
Here’s the manual page for the
--disable-log-bin option of
One comment on “Applying binary logs without adding to the binary log”
Leave a Reply
You must be logged in to post a comment.