mysqld-bin files taking up much space

Post Reply
mister_v
Posts: 188
Joined: Thu Mar 04, 2010 9:19 pm

mysqld-bin files taking up much space

Post by mister_v »

mysql.bin files taking up much space.

I have a set of files that take up lots of space:

Code: Select all

-rw-rw----. 1 mysql mysql  38M Aug 12 17:42 mysqld-bin.000019
-rw-rw----. 1 mysql mysql 888K Aug 12 20:44 mysqld-bin.000020
-rw-rw----. 1 mysql mysql  143 Aug 12 20:56 mysqld-bin.000021
-rw-rw----. 1 mysql mysql  143 Aug 12 20:58 mysqld-bin.000022
-rw-rw----. 1 mysql mysql  143 Aug 12 21:00 mysqld-bin.000023
-rw-rw----. 1 mysql mysql 8.4M Aug 15 11:42 mysqld-bin.000024
-rw-rw----. 1 mysql mysql 127K Aug 15 12:23 mysqld-bin.000025
-rw-rw----. 1 mysql mysql  143 Aug 15 12:34 mysqld-bin.000026
-rw-rw----. 1 mysql mysql  143 Aug 15 12:53 mysqld-bin.000027
-rw-rw----. 1 mysql mysql 541M Oct  6 17:05 mysqld-bin.000028
-rw-rw----. 1 mysql mysql 110M Nov  2 16:16 mysqld-bin.000029
-rw-rw----. 1 mysql mysql  25M Nov  6 17:25 mysqld-bin.000030

what are those files and can I safely delete them?
chris
Site Admin
Posts: 194
Joined: Mon Jul 21, 2008 9:52 am

Re: mysqld-bin files taking up much space

Post by chris »

These are binary log files.
The binary log contains all statements that update data or potentially could have updated it. For example, a DELETE or UPDATE which matched no rows. Statements are stored in the form of events that describe the modifications. The binary log also contains information about how long each statement took that updated data.

These binary log files are used for Data Recovery or for High availability / replication.

You can disable this (if you are NOT replicating ),
by editing my.ini or my.cnf file,
and comment out (set # in front) the following lines :

Code: Select all

#log_bin                        = /var/log/mysql/mysql-bin.log
#expire_logs_days        = 10
#max_binlog_size         = 100M
Save and restart the the mysql server:

Code: Select all

sudo /etc/init.d/mysql restart

You can also use the following command in MYSQL:
PURGE BINARY LOGS BEFORE '2015-11-01 12:00:00';
It will remove all the files that were made before this date.
Post Reply