Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Databases»MariaDB»How to Remove/PURGE BINARY LOGS in MySQL & MariaDB

    How to Remove/PURGE BINARY LOGS in MySQL & MariaDB

    RahulBy 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.

    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
    Previous ArticleHow to Resize Root Partition on Linux in Amazon EC2
    Next Article How to Add Swap Space in Ubuntu 18.04

    Related Posts

    How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04

    Updated:April 7, 20227 Mins Read

    How To Install MySQL Server on Ubuntu 22.04

    Updated:April 6, 20224 Mins Read

    How To Change MySQL User Password

    2 Mins Read

    How to Delete A MySQL User Account

    2 Mins Read

    How to Install MySQL 8.0 on Ubuntu 20.04

    Updated:February 2, 20215 Mins Read

    How to Check MySQL Version

    Updated:July 23, 20212 Mins Read

    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

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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