This article tells you how to download and delete the mysql binary log (log-bin) in MySQL command mode. If you need it, refer to it.
This article tells you how to download and delete the mysql binary log (log-bin) in MySQL command mode. If you need it, refer to it.
Find out which binary log files are currently available
The Code is as follows: |
|
Mysql> show binary logs; + ------------------ + ----------- + | Log_name | File_size | + ------------------ + ----------- + | Mysql-bin.000001 | 1357315 | | Mysql-bin.000002 | 117 | | Mysql-bin.000003 | 404002 | | Mysql-bin.000004 | 2050722 | | Mysql-bin.000005 | 139103 | | Mysql-bin.000006 | 46702 | | Mysql-bin.000007 | 117 | | Mysql-bin.000008 | 98 | | Mysql-bin.000009 | 117 | | Mysql-bin.000010 | 1254 | | Mysql-bin.000011 | 117 | | Mysql-bin.000012 | 29394942 | | Mysql-bin.000013 | 422100 | | Mysql-bin.000014 | 117 | | Mysql-bin.000015 | 117 | | Mysql-bin.000016 | 98 | | Mysql-bin.000017 | 117 | | Mysql-bin.000018 | 117 | | Mysql-bin.000019 | 285300 | | Mysql-bin.000020 | 181229 | | Mysql-bin.000021 | 98 | + ------------------ + ----------- + 21 rows in set (0.03 sec) |
Delete bin-log (delete all binary log files before mysql-bin.000018)
The Code is as follows: |
|
Mysql> purge binary logs to 'mysql-bin.20.18 '; Query OK, 0 rows affected (0.08 sec) Mysql> show binary logs; + ------------------ + ----------- + | Log_name | File_size | + ------------------ + ----------- + | Mysql-bin.000018 | 117 | | Mysql-bin.000019 | 285300 | | Mysql-bin.000020 | 181229 | | Mysql-bin.000021 | 98 | + ------------------ + ----------- + 4 rows in set (0.00 sec) |
View logs
The Code is as follows: |
|
Mysql> show binlog events; + ------------------ + ----- + ------------- + ----------- + ------------- + ----------------------------------------- + | Log_name | Pos | Event_type | Server_id | End_log_pos | Info | + ------------------ + ----- + ------------- + ----------- + ------------- + ----------------------------------------- + | Mysql-bin.000018 | 4 | Format_desc | 1 | 98 | Server ver: 5.0.45-log, Binlog ver: 4 | | Mysql-bin.000018 | 98 | Stop | 1 | 117 | + ------------------ + ----- + ------------- + ----------- + ------------- + ----------------------------------------- + 2 rows in set (0.01 sec) |