mysql删除bin-log

由于开启了主从,或者出于备份需要,mysql的配置文件中开启了log-bin

于是就产生了很多很大的bin-log

删除方法

mysql>show master logs;

+------------------+------------+
| Log_name         | File_size  |
+------------------+------------+
| mysql-bin.000139 | 1073742269 |
| mysql-bin.000140 | 1073741881 |
| mysql-bin.000141 | 1073742107 |
| mysql-bin.000142 | 1073741963 |
| mysql-bin.000143 | 1073741930 |
| mysql-bin.000144 | 1073742073 |
| mysql-bin.000145 | 1073742180 |
| mysql-bin.000146 | 1073741974 |
| mysql-bin.000147 | 1073743036 |
| mysql-bin.000148 | 1073741996 |
| mysql-bin.000149 | 1073741938 |
| mysql-bin.000150 | 1073742092 |
| mysql-bin.000151 | 1073742179 |
| mysql-bin.000152 | 1073742046 |
| mysql-bin.000153 | 1073741940 |
| mysql-bin.000154 | 1073765611 |
| mysql-bin.000155 | 1073822013 |
| mysql-bin.000156 | 1073745787 |
| mysql-bin.000157 |  614777989 |
+------------------+------------+

删除mysql-bin.000154之前的bin-log:

mysql>purge binary logs to 'mysql-bin.000154';

可以加入到crontab里定期执行, 删除N天前的bin-log

你可能感兴趣的:(mysql,数据库,职场,休闲,删除bin-log)