They are taking up too much space:
/var/lib/mysql/jiaoyou-slow.log: 53M
/var/lib/mysql/mysql-bin.000005: 68M
/var/lib/mysql/mysql-bin.000003: 1.1G
/var/lib/mysql/mysql-bin.000007: 34M
/var/lib/mysql/mysql-bin.000004: 225M
They are taking up too much space:
/var/lib/mysql/jiaoyou-slow.log: 53M
/var/lib/mysql/mysql-bin.000005: 68M
/var/lib/mysql/mysql-bin.000003: 1.1G
/var/lib/mysql/mysql-bin.000007: 34M
/var/lib/mysql/mysql-bin.000004: 225M
If you delete them at the disk level, mysql
will crash.
The command to remove them is:
PURGE BINARY LOGS TO 'mysql-bin.010';
Replace mysql-bin.010
with the last mysql-bin
file that you wish to keep - typically the last one.
See the MySQL docs for more information.
There are a few reasons to use binary logging. In order of importance:
So there are three things to check before you delete any binary logs:
If you are happy with the answers to all of those then go ahead and delete them with the PURGE
command as noted by RageZ. Absolutely don't delete them by hand because MySQL likes to keep track of them. You can either use the syntax TO
to specify a filename or BEFORE
to specify a date. You can see which file MySQL currently has open with SHOW MASTER STATUS
.
A much better approach, as kedar notes, is to use expire_logs_days
. This will automatically perform the action of purging any binary logs that are older than N days.
In Ubuntu 12.04
PURGE BINARY LOGS
Add this line to your /etc/mysql/my.cnf and it'll need to be in the [mysqld] section.
expire_logs_days = 7
After:
/etc/init.d/mysql restart
Or:
Then log into Mysql and run this command to set the variable without having to restart Mysql.
SET GLOBAL expire_logs_days=7;