Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Databases»MariaDB»How to Remove/PURGE BINARY LOGS in MySQL & MariaDB

    How to Remove/PURGE BINARY LOGS in MySQL & MariaDB

    By RahulJuly 22, 20152 Mins Read

    Binary log files contains data about modification’s make by MySQL server. You can see there are multiple binary files will be available on your MySQL server and there will be one .index file which contains names of all binary files to keep track of them.

    Advertisement

    Step 1. List Binary Files

    First list binary log files in your system and find out how old binary log files you want to delete. These files generally located under /var/lib/mysql directory.

    # ls -a /var/lib/mysql 
    
    ...
    -rw-rw---- 1 mysql mysql   3800220 Jul 21 15:15 mysql-bin.000733
    -rw-rw---- 1 mysql mysql   1076727 Jul 21 15:40 mysql-bin.000734
    -rw-rw---- 1 mysql mysql    263024 Jul 21 15:42 mysql-bin.000735
    -rw-rw---- 1 mysql mysql  13895153 Jul 22 00:36 mysql-bin.000736
    -rw-rw---- 1 mysql mysql   2717571 Jul 22 01:02 mysql-bin.000737
    -rw-rw---- 1 mysql mysql   4080285 Jul 22 03:49 mysql-bin.000738
    ...
    

    Step 2. PURGE Binary Logs

    Now use any one of following commands to delete older binary log files as per your system requirements.

    • Delete binary log file mysql-bin.000735 or older files.
      mysql> PURGE BINARY LOGS TO 'mysql-bin.000735';
      
    • Delete all binary log files created till date “2015-07-21 23:59:59”.
      mysql> PURGE BINARY LOGS BEFORE '2015-07-21 23:59:59';
      

    Now list binary log files again, You will find that all older logs has been removed from mysql directory.

    bin-log binary log
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Installing MySQL 8.0 on Amazon Linux 2

    How To Install MySQL 8 on Amazon Linux 2

    (Resolved) Unknown collation: utf8mb4_unicode_520_ci

    How To Install phpMyAdmin on Ubuntu 22.04

    How To Install phpMyAdmin on Ubuntu 22.04

    View 2 Comments

    2 Comments

    1. Robi Erwin Setiawan on July 30, 2021 1:35 pm

      I already login to MySQL using the root account but when executed purge binary.

      It just showed this Query OK, 0 rows affected (0.000 sec).

      And there’s no deleting file

      Reply
    2. john on May 15, 2016 6:33 am

      I did not know that these logs can be deleted from mysql
      thank you

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Split Large Archives in Linux using the Command Line
    • System.out.println() Method in Java: A Beginner’s Guide
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.