browser icon
You are using an insecure version of your web browser. Please update your browser!
Using an outdated browser makes your computer unsafe. For a safer, faster, more enjoyable user experience, please update your browser today or try a newer browser.

Remove MySQL Binary Log Files Eating Lots of Disk Space

Posted by on December 6, 2010

By default, MySQL 5.0 and above enables MySQL Binary Log. Keeping MySQL Binary Log might take up a lot of disk space for long run. Older MySQL Binary log can be removed in order to keep your hard disk space free.

MySQL Binary Log stores query event such as add, delete and update in a very details way. The Binary Log is used for two main purposes;

* 1. Replication between master and slave server, statement that has been made on Master server will later send it to slave server.
* 2. Recovery, certain recovery job required data stored in MySQL Binary Log.

MySQL binary log locate at folder data on database root file, with the naming convention of mysql-bin.. Sample of the binary files as shown below;

Can I remove MySQL Binary Log ?

Of course yes (drinking), as long as the data is replicated to Slave server, it’s safe to remove the file. It’s recommend only remove MySQL Binary Log older than 1 month.

Besides, if Recovery of data is the main concern, it’s recommend to archive MySQL Binary Log.

There are several ways to remove or clean up MySQL Binary Log, it’s not recommend to clean up the file manually, manually means running the remove command.

Purge Master Logs

If you ARE replicating, then you need to periodically RESET MASTER or PURGE MASTER LOGS to clear out the old logs as those files are necessary for the proper operation of replication. Use following command to purge master logs:

$ mysql -u root -p ‘MyPassword’ -e “PURGE BINARY LOGS TO ‘mysql-bin.03’;”

OR

$ mysql -u root -p ‘MyPassword’ -e “PURGE BINARY LOGS BEFORE ‘2008-12-15 10:06:06’;”

Comments

comments

One Response to Remove MySQL Binary Log Files Eating Lots of Disk Space

  1. description here

    Hello, Neat post. There is a problem together with your website in web explorer,
    might check this? IE nonetheless is the market leader and a good component of folks will pass over your wonderful
    writing due to this problem.

Leave a Reply

Your email address will not be published. Required fields are marked *

:)) :) :D (LOL) :-P (woot) ;-) :-o X-( ;-( :-& (angry) (annoyed) (bye) B-) (cozy) (sick) (: (goodluck) (griltongue) (mmm) (hungry) (music) (tears) (tongue) (unsure) (highfive) (dance) (doh) (brokenheart) (drinking) (girlkiss) (rofl) (money) (rock) (nottalking) (party) (sleeping) (thinking) (bringit) (worship) (applause) 8-) (gym) (heart) (devil) (lmao) (banana_cool) (banana_rock) (evil_grin) (headspin) (heart_beat) (ninja) (haha) (evilsmirk) (bigeyes) (funkydance) (idiot) (lonely) (scenic) (hassle) (panic) (okok) (yahoo) (blush) (fish_hit) (muhaha) (muscle) (taser) (beer) (coffee) (banana_ninja) (goal) (fireworks) (smileydance) (dance_bzz) (rusian)