Mysql – Unable to show binary logs how to remove logs from thesql

binloglogsMySQLmysql-5.1

Server version: 5.1.50-log MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show binary logs ;

PROBLEM

  • Data directory is full
  • I want to remove space
  • Purge is not making more space.

Any idea what to do to clear relay logs and Bin file .

Best Answer

When the folder with binary logs is full, mysqld will freeze everything that does a write to a MyISAM table (even temporary MyISAM tables). See my post "Site Offline" MySQL server failing to start and stop as to why. Anyway, mysqld will wait for free diskspace before continuing whatever operation it was doing. In this particular instance, you must go to the OS and delete the binary logs, but not all of them.

For example, if you defined

[mysqld]
datadir=/var/lib/mysql
log-bin=mysql-bin
log-error=error-log.log

go to the OS and run this

cd /var/lib/mysql
ls -l mysql-bin.*

You will see all the binary logs. Delete just the first 2 or 3 binary logs.

Log back into mysql and run SHOW BINARY LOGS;

It will eventually kick in when the free space is acknowledged by mysqld.

Then, you can run PURGE BINARY TO 'mysql-bin.xxxxxx';

You may also have to look into the error log or slow log. If they are big, truncate them like this:

cd /var/lib/mysql
echo -n > error-log.log

GIVE IT A TRY !!!