Mysql : how to purge binary logs when you have no space left on device ?

Discussion in 'Server Operation' started by Christophe Casalegno, Mar 28, 2017.

  1. Hi all, perhaps that can help you : with this line you can purge 50% of your binary logs if you can't connect to MySQL. Note : you must stop MySQL before doing this !

    cd /var/lib/mysql && a=`ls |grep -v relay |grep bin.index` && b=`wc -l <$a` ; c=`echo $(($b/2))` |xargs -l rm ; echo $c | head -n $b $a |cut -d "/" -f2 && sed 1,$c\d $a -i

    For more details, verifications, etc. you can look at : http://www.christophe-casalegno.com...y-logs-when-you-have-no-space-left-on-device/
    kind regards,
     

Share This Page