mysql清理binlog日志
Posted 小刀
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql清理binlog日志相关的知识,希望对你有一定的参考价值。
mysql的binlog日志过多过大,清理过程。
1.查看binlog日志
mysql> show binary logs; +------------------+-----------+ | Log_name | File_size | +------------------+-----------+ | mysql-bin.000001 | 13255920 | | mysql-bin.000002 | 143716 | | mysql-bin.000003 | 524288119 | | mysql-bin.000004 | 524288076 | | mysql-bin.000005 | 520461264 | | mysql-bin.000006 | 4768739 | | mysql-bin.000007 | 469726614 | | mysql-bin.000008 | 524291087 | | mysql-bin.000009 | 524288353 | | mysql-bin.000010 | 524289342 | | mysql-bin.000011 | 524288703 | | mysql-bin.000012 | 274820426 | +------------------+-----------+ 12 rows in set (0.00 sec)
2.删除某个日志文件之前的所有日志文件
mysql> purge binary logs to ‘mysql-bin.000012‘; Query OK, 0 rows affected (0.59 sec) mysql> show binary logs; +------------------+-----------+ | Log_name | File_size | +------------------+-----------+ | mysql-bin.000012 | 275418857 | +------------------+-----------+ 1 row in set (0.00 sec)
3.重置日志
mysql> reset master; Query OK, 0 rows affected (0.21 sec) mysql> show binary logs; +------------------+-----------+ | Log_name | File_size | +------------------+-----------+ | mysql-bin.000001 | 5059 | +------------------+-----------+ 1 row in set (0.00 sec)
注意,如果是主从复制,修改主后,slave上会报错,需要在slave重新设置同步。
slave操作:
mysql> stop salve; mysql>change master to master_host=‘192.168.100.10‘,master_user=‘rep‘,master_password=‘123456‘, master_log_file=‘mysql-bin.000001‘,master_log_pos=5059; mysql> show slave statusG;
以上是关于mysql清理binlog日志的主要内容,如果未能解决你的问题,请参考以下文章