what will happen to the binary log if it reaches its maximum value ? Does it reset to mysql-bin.00001 again ?

I know the below points exist means, there won't be any reset happen in binlogs.

  1. I would like to know whats the maximum value for the bin-log files.

  2. In case, the expire_log_days not provided, then it should not replace the first file, throws 'file-exist' error. The logs will be kept forever unless you specify an expiry.

  3. If the binary log master index files having the entry, I don't think it will replace.

Then what will happen eventually?

  • Do the math. How many binlogs do you generate per day? How many days before the number hits the max? How many years is that?
    – Rick James
    Mar 4, 2015 at 2:36

1 Answer 1


If the binlog file number reaches its maximum value, it appears the server will throw an error.

However, the maximum value is not 999999 as it would appear ... it's 2,147,483,647.

From the source file sql/log.h (MySQL 5.6 source tree):


Other relevant files are sql/binlog.cc and sql/log.cc. The code that generates log file names zero-pads values to 6 digits after incrementing the current largest number by 1, but sprintf(ext_buf, "%06lu", next) will not truncate larger numbers, it just won't pad them... so mysql-bin.999999 would be followed by mysql-bin.1000000.

And, according to the Google Machine, somebody apparently tried it just to make sure.

  • It means, it will throw error right.
    – s_ramesh
    Mar 4, 2015 at 5:23
  • It will continue growing past 6 digits and will not throw an error until mysql-bin.2147483647 is reached... over two billion binlogs. Mar 4, 2015 at 6:05

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.