时间:2021-07-01 10:21:17 帮助过:4人阅读
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 status\G;
mysql清理binlog日志
标签:bin class 主从 stat nlog eset change mysql-bin stop