欢迎来到天天文库
浏览记录
ID:33159116
大小:44.95 KB
页数:3页
时间:2019-02-21
《mysql如何删除 bin log》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、【MySql】如何删除binlog一语法如下:PURGE{MASTERBINARY}LOGSTO'log_name'PURGE{MASTERBINARY}LOGSBEFORE'date'用于删除在指定的日志或日期之前的日志索引中的所有二进制日志。这些日志也会从记录在日志索引文件中的清单中被删除,这样被给定的日志成为第一个。例如:1删除指定日志之前的binlogPURGEMASTERLOGSTO'mysql-bin.010';1)查看当前的logmysql>showbinarylogs;+-----------
2、-------+-----------+Log_name File_size+------------------+-----------+mysql-bin.000001 126mysql-bin.000002 88416282mysql-bin.000003198081520mysql-bin.000004 1358mysql-bin.000005 126mysql-bin.000006 126mysql-bin.000007 126mysql-bin.000008 315m
3、ysql-bin.000009 126mysql-bin.000010 126mysql-bin.000011 504mysql-bin.000012 107mysql-bin.000013 107mysql-bin.000014 107mysql-bin.000015 107mysql-bin.000016 521mysql-bin.000017 315mysql-bin.000018 958+------------------+-----------+18rows
4、inset(0.04sec)2)删除mysql-bin.000010之前的日志mysql>purgebinarylogsto'mysql-bin.000010';QueryOK,0rowsaffected(0.35sec)mysql>showbinarylogs; +------------------+-----------+Log_name File_size+------------------+-----------+mysql-bin.000010 126mysql-
5、bin.000011 504mysql-bin.000012 107mysql-bin.000013 107mysql-bin.000014 107mysql-bin.000015 107mysql-bin.000016 521mysql-bin.000017 315mysql-bin.000018 958+------------------+-----------+9rowsinset(0.00sec)3)显示第一个二进制日志: mysql>showbinlogevents
6、;+------------------+-----+-------------+-----------+-------------+---------------------------------------+Log_name PosEvent_type Server_idEnd_log_posInfo +------------------+-----+-------------+-----------+-------------+-----------------
7、----------------------+mysql-bin.000010 4Format_desc 1 107Serverver:5.5.18-log,Binlogver:4mysql-bin.000010107Stop 1 126 +------------------+-----+-------------+-----------+-------------+-------------------------------------
8、--+2rowsinset(0.01sec)2删除指定日期之前的binlogPURGEMASTERLOGSBEFORE'2011-12-0513:00:00';3清除N天前的binlogPURGEMASTERLOGSBEFOREDATE_SUB(NOW(),INTERVALNDAY);BEFORE变量的date自变量可以为'YYYY-MM-DDhh:mm:ss'格式。MASTER和BINARY是同义
此文档下载收益归作者所有