1

I'm looking for a way to extend the SHOW BINARY LOGS command to show the created date, or to at least show the time range each log is applicable for.

Is there a way to do this within MySQL or am I going to have to read each log individually to check what time period it covers?

1

MySQL doesn't store metadata about binary logs (well, it does, but only to control current and/or executed commands, not about the binlog themselves).

You can use SHOW BINLOG EVENTS to read the actual binlogs, but that most likely will not be helpful, and will be very slow (it just read the logs). Yes, the only way I can think of is to read the actual logs with mysqlbinlog and check the second line after the log position of the first and last events.

# at 256
#181130  9:28:36 server id 123  end_log_pos 545

If you don't need exact dates, there may be a shortcut for avoid reading the whole log- you can use the mtime (last modified time) of the filesystem metadata to get an aproximation of when it was last written (but not that will not be 100% acurate- flushing may be delayed by the filesystem, and the time the log was written may be different than that of when one the transaction was executed. But it may be a shortcut if you just want to find a particular event before reading just the one you are intereted in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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