mysql二进制日志管理

06ab792b1792082c98122d55bd03977c

1.刷新日志

mysql > flush logs;

2.查看当然数据库binlog信息

mysql > show binary logs;  或者show master logs;

//查看当前的日志文件

mysql> show master status;

//删除所有本机上的二进制日志

mysql> RESET MASTER;

+------------------+-----------+
| Log_name | File_size |
+------------------+-----------+
| mysql-bin.000041 | 149 |
| mysql-bin.000042 | 149 |
| mysql-bin.000043 | 106 |
+------------------+-----------+

3.清除历史log,保留最近的

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

4.查看本地binlog文件
# ls -l /var/lib/mysql/ | grep bin.
-rw-rw----  1 mysql mysql      19 Jan 16 11:07 master-bin.index
-rw-rw----  1 mysql mysql  5875412 Jan 16 11:31 mysql-bin.000043

备份中清除日志
# mysqldump --flush-logs --delete-master-logs

//看二进制日志文件用mysqlbinlog

mysql>show binlog events in "mysql-bin.000049";

发表评论


表情