1: Enter MYSQL client input
Mysql> show binary logs;
+ ------------------ + ------------ +
| Log_name | file_size |
+ ------------------ + ------------ +
| Mysql-bin.000001 | 117 |
| Mysql-bin.000002 | 755584845 |
| Mysql-bin.000003 | 402552787 |
| Mysql-bin.000004 | 411062 |
| Mysql-bin.000005 | 350535699 |
| Mysql-bin.000006 | 92833030 |
| Mysql-bin.000007 | 763257 |
| Mysql-bin.000008 | 17786102 |
| Mysql-bin.000009 | 1073741955 |
| Mysql-bin.000010 | 566312775 |
+ ------------------ + ------------ +
10 rows in SET (0.00 Sec)
Mysql>
Then we can see the list of bin-log logs.
2. delete bin-log (delete all binary log files before mysql-bin.000018)
Mysql> purge binary logs to 'mysql-bin.000005 ';
If your server's hard disk is not large enough, slave and master's bin-log will occupy a large disk. The clear solution is as follows:
Solution 1:
1. on the slave server, use show slave status to check which log it is reading.
2. Show master logs or show binary logs on the master server to obtain a series of logs on the master server.
3. Delete the log by purge according to the relay_master_log_file of slave.
Solution 2:
Set the master's expire_logs_days
Mysql>
Mysql> show binary logs;
+ ---------------- + ------------ +
| Log_name | file_size |
+ ------------------ + ------------ +
| Mysql-bin.000001 | 117 |
| Mysql-bin.000002 | 755584845 |
| Mysql-bin.000003 | 402552787 |
| Mysql-bin.000004 | 411062 |
| Mysql-bin.000005 | 350535699 |
| Mysql-bin.000006 | 92833030 |
| Mysql-bin.000007 | 763257 |
| Mysql-bin.000008 | 17786102 |
| Mysql-bin.000009 | 1073741955 |
| Mysql-bin.000010 | 566312775 |
+ ------------------ + ------------ +
10 rows in SET (0.00 Sec)
Mysql> set global expire_logs_days = 7;
Query OK, 0 rows affected (0.00 Sec)
Mysql> flush logs;
Query OK, 0 rows affected (2.16 Sec)
Mysql> show binary logs;
+ ------------------ + ----------- +
| Log_name | file_size |
+ ------------------ + ----------- +
| Mysql-bin.000010 | 566592340 |
| Mysql-bin.000011 | 6410 |
+ ------------------ + ----------- +
2 rows in SET (0.00 Sec)
Mysql>