Wednesday, September 13, 2023

.::: Clear out /Cleansing MySql MariaDB binary log files :::.

A. clearing using interval day

1. show binary logs before;


MariaDB [(none)]> show binary logs;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000001 |       389 |
| mysql-bin.000002 |      1110 |
| mysql-bin.000003 |      9773 |
| mysql-bin.000004 |       342 |
+------------------+-----------+
4 rows in set (0.000 sec)

MariaDB [(none)]> 

2. purge binari log using interval day

purge binary logs before date(now() - interval 2 day);

MariaDB [(none)]> purge binary logs before date(now() - interval 2 day);
Query OK, 0 rows affected (0.006 sec)

MariaDB [(none)]>


3. show binary logs after;
show binary logs;

MariaDB [(none)]> show binary logs;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000004 |       342 |
+------------------+-----------+
1 row in set (0.000 sec)

MariaDB [(none)]>

 
 



B. clearing using binary log file name

1. show binary logs before;


MariaDB [(none)]> show binary logs;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000009 |       365 |
| mysql-bin.000010 |       365 |
| mysql-bin.000011 |       365 |
| mysql-bin.000012 |       365 |
| mysql-bin.000013 |       365 |
| mysql-bin.000014 |       365 |
| mysql-bin.000015 |       365 |
| mysql-bin.000016 |       365 |
| mysql-bin.000017 |       342 |
+------------------+-----------+
9 rows in set (0.000 sec)

MariaDB [(none)]>

2. PURGE BINARY LOGS TO 'mysql-bin.000015';

MariaDB [(none)]> PURGE BINARY LOGS TO 'mysql-bin.000015';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]>


3. show binary logs after;

MariaDB [(none)]> show binary logs;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000015 |       365 |
| mysql-bin.000016 |       365 |
| mysql-bin.000017 |       342 |
+------------------+-----------+
3 rows in set (0.000 sec)

MariaDB [(none)]>
 

  

No comments:

Post a Comment

Popular Posts