Disable MySQL binary logging

MySQL can keep a so-called binary log of transactions, which keeps track of all updates to the database. It is used for database restoration and replication.

The logs can grow very quickly in size. At the time of writing, my logs take up around 68G.

I use the database in question as a dump for backups taken from various other servers, so it is not necessary for me to keep transaction logs.

How to turn off binary logging

Edit your my.cnf file and comment out the log-bin option. Also make sure that expire_log_days option is missing or commented out.

#expire_logs_days = 10

Then restart mysql.

How to delete the binary logs

If you have not configured a custom basename for the log files, it is likely they are stored using your domain name, e.g. localhost-bin.000001. I believe older versions of MySQL used "mysql" as the basename, so look for mysql-bin.000001. There will also be an index file with a .index extension.

Back up all of these files. Then delete them. Restart mysql and all should be fine.


The steps above came from a comment in section 5.2.6. Server Log Maintenance of the MySQL 5.1 manual. I tried for a significant period of time to locate official MySQL documentation about the log-bin option in my.cnf, but amazingly didn't find anything.

Last modified: 28/05/2008 Tags: (none)

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top