MySQL : Till when MySQL retains binary logs? I have multiple queries :

Till when does MySQL retain the binary logs ? What is the default setting ? When does it start logging ?

What does the number of the binary log file name suggest for example in mysql-bin.xxxxxx what does xxxxxx signify.

I have oldest file with name mysql-bin.000163 how can check whether this file was the first binary log file ?

mysql-bin.index contains :

/var/log/mysql/mysql-bin.000163
/var/log/mysql/mysql-bin.000164
/var/log/mysql/mysql-bin.000165
/var/log/mysql/mysql-bin.000166
/var/log/mysql/mysql-bin.000167
/var/log/mysql/mysql-bin.000168
/var/log/mysql/mysql-bin.000169
/var/log/mysql/mysql-bin.000170
/var/log/mysql/mysql-bin.000171
/var/log/mysql/mysql-bin.000172
/var/log/mysql/mysql-bin.000173
/var/log/mysql/mysql-bin.000174
/var/log/mysql/mysql-bin.000175
/var/log/mysql/mysql-bin.000176
/var/log/mysql/mysql-bin.000177
/var/log/mysql/mysql-bin.000178
/var/log/mysql/mysql-bin.000179
/var/log/mysql/mysql-bin.000180
/var/log/mysql/mysql-bin.000181
/var/log/mysql/mysql-bin.000182
/var/log/mysql/mysql-bin.000183
/var/log/mysql/mysql-bin.000184
/var/log/mysql/mysql-bin.000185
/var/log/mysql/mysql-bin.000186
/var/log/mysql/mysql-bin.000187
/var/log/mysql/mysql-bin.000188
/var/log/mysql/mysql-bin.000189
The number in the mysql-bin.nnnnnn filename is simply a sequence number.  This gets updated every time a FLUSH LOGS is initiated, either manually or through predetermined means and is sequential (e.g. normally starts at 00001 and goes up).

The logs will be kept forever unless you specify an expiry.  This should be done in your MySQL configuration:

http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_expire_logs_days

You can also delete the binary logs manually within MySQL by using the command:

PURGE BINARY LOGS .... [TO FILENAME | BEFORE 'DATE' ]


See details here http://dev.mysql.com/doc/refman/5.6/en/purge-binary-logs.html

It is possible to delete the files manually (outside of MySQL) but NOT recommended.

See http://dev.mysql.com/doc/refman/5.6/en/binary-log.html for details on the binary logging system.