If you have set up binary logging and wish to restore a binary log, but want to omit one or more specific SQL statements from a data recovery, you can do so by using the mysqlbinlog utility and redirecting the results to a text file for editing. When you’re finished you can pass the edited file to MySQL for processing through the mysql client. To redirect the output from mysqlbinlog, you would enter something like this:
mysqlbinlog /var/log/mysql/bin.123456 \ > /tmp/mysql_restore.sql
This will create a simple text file in the /tmp directory (you would adjust the path for your server). This accomplished by using the redirect (i.e., the greater-than sign). Incidentally, the backslash on the first line is to indicate that the command is spread over two lines. You can edit the text file created with a text editor like vi or notepad.exe. Don’t use a word processor because it may add binary formatting codes to the file, which will cause problems when you hand the file over to mysql. After you’ve deleted the unwanted SQL statements and saved the restore file, you can then run it through the mysql client like so:
mysql -u root -pmypwd \ < /tmp/mysql_restore.sql
Notice that in this case, a less-than sign is used to redirect the standard input (i.e., STDIN).