Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have over 500 files in my /var/lib/mysql folder named mysql-bin.000522 (or some variation thereof)...each is anywhere from a couple megabytes to 1.1GB. Overall, these files are taking up >400GB on our system. How are these being created? Are they safe to delete? If they're not necessary, how can we prevent them from being re-created?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

It's all in the MySQL documentation that they are binary log files for data recovery and synchronizing.

Look at the documentation on how to get rid of them. But make sure that you don't need them in your current setup.

share|improve this answer
    
that was it.thx –  user70981 Aug 6 '11 at 0:57

As already mentioned those files are for binary logging. If you're not using them, you can issue a RESET MASTER to remove them.

I would also then stop the server, and add a new configuration variable to your my.cnf. expire_log_days will tell the server to keep the binary logs for the amount of days you specify, to prevent further buildup in the future.

You could also turn off binary logging by making sure the bin_log option is not set, but this is not the recommended route. A better solution would be to develop a backup and restore strategy so that if you do have a database crash, you can recover from it.

One such example, on a low-write server, would be to take a full backup once weekly. Then you would have the binary logs for 7 days (14 to be safe) to replay any changes from the full backup.

Here is what MySQL has to say about backing up and restoring.

share|improve this answer
    
when you say "take a full backup once weekly" what do you mean? Having binary logging on will automatically do the backups, no? –  user70981 Aug 6 '11 at 1:01
    
@user70981 The binary logs only record the changes made, so you'd have to have every log file ever in order to restore the database, and you'd have to sit there while all hundreds (thousands?) of them were imported back into the DB. By making an actual backup of the database, you only need backup plus the log files since that backup to restore the data. –  DerfK Aug 6 '11 at 1:35
    
ahhh, I see what you're saying. thx! –  user70981 Aug 6 '11 at 1:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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