美文网首页
清理mysql bin-log二进制日志文件

清理mysql bin-log二进制日志文件

作者: 黑客不黑_ | 来源:发表于2019-07-18 11:00 被阅读0次

1.查看binlog日志

mysql> show binary logs;
+---------------+-----------+
| Log_name      | File_size |
+---------------+-----------+
| binlog.007480 |       198 |
| binlog.007481 |       795 |
| binlog.007482 |   1203872 |
| binlog.007483 |       795 |
| binlog.007484 |       198 |
| binlog.007485 |       795 |
| binlog.007486 |   1482097 |
| binlog.007487 |       795 |
| binlog.007488 |       198 |
| binlog.007489 |       789 |
| binlog.007490 |   1333935 |
+---------------+-----------+
11 rows in set (0.00 sec)

2、删除某个日志文件之前的所有日志文件

mysql> purge binary logs to 'binlog.007488';
Query OK, 0 rows affected (0.13 sec)

mysql> show binary logs;
+---------------+-----------+
| Log_name      | File_size |
+---------------+-----------+
| binlog.007488 |       198 |
| binlog.007489 |       789 |
| binlog.007490 |   1389313 |
+---------------+-----------+
3 rows in set (0.08 sec)

3、重置所有日志

日志文件编号又从000001开始

mysql> reset master;
Query OK, 0 rows affected (0.22 sec)

mysql> show binary logs;
+---------------+-----------+
| Log_name      | File_size |
+---------------+-----------+
| binlog.000001 |      2644 |
+---------------+-----------+
1 row in set (0.00 sec)

4、关闭mysql的binlog日志

#log-bin=mysql-bin  在my.cnf里面注释掉binlog日志

重启mysql

service mysqld restart

相关文章

网友评论

      本文标题:清理mysql bin-log二进制日志文件

      本文链接:https://www.haomeiwen.com/subject/sgmklctx.html