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?

2 Answers 2


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


If you already know the position of the query in question, there's no reason you can't mysqlbinlog an open binlog. Sure you won't see anything that gets added to the log after you open it, but you can pipe it through less and search for the query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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