# MySQL is eating my /var

## Napalm Llama

I returned home today to notice that my emerge -e world had failed due to lack of disk space.  On further investigation, it turns out that /var is 100% full - with over 2.5Gb of its 4Gb residing in /var/lib/mysql.

Now all I knowingly use MySQL for on a regular basis is my Amarok database, and I'm fairly sure that's not whats causing it.  There are a couple of massive files called /var/lib/mysql/splig-bin.000xxx (splig is my hostname), the largest of which is just a shade over 1Gb.

Now I don't know a lot about MySQL, so could someone tell me if these files are really needed?  Have I been pwnd?  What's going on?

Cheers,

NL  :Confused: 

----------

## kashani

What you're seeing are bin-log logs. Mysql writes them and uses them for table recovery and replication. To see what Mysql is logging do

```
 mysqlbinlog <filename> | less 
```

If a db crash won't bother you greatly or you feel that nightly backups are fine since you're db doesn't update often then remove the bin-log line from your /etc/mysql/my.cnf, restart mysql, and then delete them. 

However I recommend putting a weekly cron in that runs the following which will remove all but the last seven days of logs. That should solve your space issues and keep enough logs for Mysql to use for recovery if needed.

```
PURGE MASTER LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 7 DAY);
```

kashani

----------

## Napalm Llama

Cool - just one thing, though.  I'm assuming here that your command is SQL, in which case, where do I put it to get it automated?

----------

## zeek

 *Napalm Llama wrote:*   

> Cool - just one thing, though.  I'm assuming here that your command is SQL, in which case, where do I put it to get it automated?

 

I think this should work.  In /etc/mysql/my.cnf add

```
expire_logs_days = 1
```

Adjust 1 to how many days you want to keep logs around.

----------

## robin_elvin

Excellent! I was wondering why my filesystem was full   :Embarassed: 

Just as a side note

```
expire_logs_days = 1
```

goes in the

```
[mysqld]
```

section of /etc/mysql/my.cnf

----------

## madhusker

I am surprised that this is not listed in the config file.  At least put it in the file,, commented out or something!!!

This "feature" ate my machine for lunch with 24G of useless logs.

A sane default of 30 days or something would be nice.

----------

## Acoc

I agree, it doesn't make sense why they wouldn't, because I think if you set it to 0, it serves the same function as having it off.  They should at least set it at 0 and put comments about what it does.

John

----------

## olsberg

I totally agree on this proposal. I still do not the the line in my.cnf and my mysql installation eats up 20GB in five days - resulting in server downtime.

Line now added manually, but gosh, this has been a time-consuming search for solutions.

----------

## PraetorZero

This is an old topic but still very relevant.  I've ran into this twice now in the past 6 months and only just now found this thread.

----------

## Napalm Llama

Hmm, does anyone else feel like filing a bug report asking for the default setting to be changed, or shall I?  It won't happen otherwise.

----------

