MySQL : binary log files

MySQLMySQL uses the so called binary log files to implement master/slaves replication.

You can set the expire_logs_days variable in your my.cnf file, which will set the number of days MySQL will keep those binary log files.

This is the longest time a MySQL replication slave can lag behind the master. If for a reason the slave is not able to replicate for more than this duration, then it won’t be able to catch back (you will have to get back data from the server one way or another)

To clean the binary log files you can use the “PURGE MASTER LOGS” SQL command which can delete binary logs before a specified date or till a specified binary log file.

To see the binary log files on the server, you can use the “SHOW BINARY LOGS” SQL command.

At last, to know up to which file you could delete the binary log files, you can run the “SHOW SLAVE STATUS” on each replication slave to see which binary log file they are using, and delete up to the oldest of them.

3 thoughts on “MySQL : binary log files”

  1. Hey I just noticed I’m on your blogroll. Now I really do need to learn linux. I’m honored, I’ll talk to you soon. Emma

  2. Hi sir,
    i am now working in WINDOWS platform using PHP and MYSQL before that i worked in LINUX platform using C++ and MYSQL and in that i used logfile for last query i have executed in MYSQL but i cant find that in WINDOWS now so can you help me to get out from this situation.

Comments are closed.