MySQL – Partial mysqlbinlog on Latest Binlog File

binlogMySQLmysqlbinlog

I'm trying to do a partial mysqlbinlog on the latest binary log file at a certain position therein (trying to extract just one query).

mysqlbinlog --start-position=1234 --stop-position=1234 /var/lib/mysql/mysql-bin.000021

The output contains:

Warning: this binlog is either in use or was not closed properly.

How do I force MySQL to start logging in the next binlog file (i.e. mysql-bin.000022) and release the original file so I can use mysqlbinlog it?

Is there another solution to this problem?

Best Answer

You can use FLUSH LOGS to rotate the binlog before it reaches max size.