码迷,mamicode.com
首页 > 数据库 > 详细

mysql日志清理

时间:2014-07-24 17:24:35      阅读:394      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   文件   数据   2014   for   

mysql bin-log 日志清理


发现mysql数据库目录中bin-log中日志文件非常大

[root@localhost var]# du -sh mysql-bin* | sort
1020K   mysql-bin.000002
1.1G    mysql-bin.000021
1.1M    mysql-bin.000018
136K    mysql-bin.000019
172K    mysql-bin.000014
191M    mysql-bin.000013
224M    mysql-bin.000017
28K     mysql-bin.000001
3.5M    mysql-bin.000012
4.0K    mysql-bin.000003
4.0K    mysql-bin.000004
4.0K    mysql-bin.000005
4.0K    mysql-bin.000006
4.0K    mysql-bin.000007
4.0K    mysql-bin.000015
4.0K    mysql-bin.000016
4.0K    mysql-bin.index
5.5M    mysql-bin.000011
63M     mysql-bin.000008
64K     mysql-bin.000009
65M     mysql-bin.000022
72K     mysql-bin.000010
863M    mysql-bin.000020
[root@localhost var]#
登陆到mysql查看bin-log
mysql> show binary logs;
+------------------+------------+
| Log_name         | File_size  |
+------------------+------------+
| mysql-bin.000001 |      27338 |
| mysql-bin.000002 |    1038693 |
| mysql-bin.000003 |       1272 |
| mysql-bin.000004 |        126 |
| mysql-bin.000005 |        126 |
| mysql-bin.000006 |        126 |
| mysql-bin.000007 |        126 |
| mysql-bin.000008 |   64950073 |
| mysql-bin.000009 |      57911 |
| mysql-bin.000010 |      69548 |
| mysql-bin.000011 |    5735460 |
| mysql-bin.000012 |    3564763 |
| mysql-bin.000013 |  199226556 |
| mysql-bin.000014 |     170872 |
| mysql-bin.000015 |        838 |
| mysql-bin.000016 |        126 |
| mysql-bin.000017 |  233747353 |
| mysql-bin.000018 |    1128493 |
| mysql-bin.000019 |     133652 |
| mysql-bin.000020 |  903932814 |
| mysql-bin.000021 | 1073745163 |
| mysql-bin.000022 |   67963674 |
+------------------+------------+
22 rows in set (0.00 sec)

mysql> 

 


删除2014-06-01 00:01:01 之前的日志:

mysql> PURGE BINARY LOGS BEFORE 2014-06-01 00:01:01;   
Query OK, 0 rows affected (0.21 sec)

mysql> 

 



++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
保留最后一次bin-logs

mysql> PURGE BINARY LOGS TO mysql-bin.000022;
Query OK, 0 rows affected (0.60 sec)
mysql>
mysql>
mysql>
mysql>
mysql>
mysql> show binary logs;                  
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000022 |  68830784 |
+------------------+-----------+
1 row in set (0.00 sec)

mysql>

 






mysql日志清理,布布扣,bubuko.com

mysql日志清理

标签:style   blog   color   os   文件   数据   2014   for   

原文地址:http://www.cnblogs.com/osxlinux/p/3865721.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!