惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
IT之家
IT之家
博客园_首页
人人都是产品经理
人人都是产品经理
博客园 - Franky
I
InfoQ
Recent Announcements
Recent Announcements
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
Microsoft Security Blog
Microsoft Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog RSS Feed
MongoDB | Blog
MongoDB | Blog
雷峰网
雷峰网
博客园 - 聂微东
N
Netflix TechBlog - Medium
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
D
Docker

博客园 - Bruse

【收藏】Windows 8 Consumer Preview的108个运行命令及简要说明 【转载】菜鸟进阶达人攻略 苹果iPad使用小技巧 Razor语法总结 省空间,教你将C盘iTunes的IPhone备份文件完整的移到其他盘 【翻译】The Repository Pattern with EF code first & Dependeny Injection in ASP.NET MVC3 【原创】越狱以后的iPhone从4.3.3升级到5.0.1时遇到的一些问题的解决办法总结 【转载】SQL Server 中几个有用的特殊函数 EF中DataContext创建的两段代码收藏 T-SQL查询进阶--流程控制语句 【转载】ASP.NET 尖括号 百分号 井号 等号 的用法 【转载】生活常识,人人必备 【转载】ASP.Net程序开发性能优化---数据库优化 关于IIS在使用中遇到的一些问题的总结 【转载】关于IPhone/IPad升级的那点事 【转载】MySql数据备份方案 【转载】mysql5.1免安装的使用及其配置说明 Apple越狱后超级实用的Cydia常用源推荐 MySQL数据库备份与恢复的详细说明 分享45个海量免费电子书下载网站
【转载】MySql中如何限制日志文件的无限制扩张
Bruse · 2011-03-31 · via 博客园 - Bruse

If your MySQL binary log files are a “Growing” problem… there are a few simple steps you can use to curtail their growth and save your disk space from these huge files.

They probably look like:

mysql-bin.000001
mysql-bin.000002
mysql-bin.000003
mysql-bin.000004
mysql-bin.000005

And around 1 gig in size each.

These files are generated when you have log-bin=mysql-bin or other log-bin= line in your /etc/my.cnf configuration file.

There are two ways to fix this problem:

The first is to stop the MySQL server from creating these binary files. The only reason you would need the binary log files is if you are doing mysql replication from a master to a slave. In this case, these files are necessary, at least until the slave(s) has caught up with the master. To stop this from logging, comment out (using #) the line containing ‘log-bin’.

The second is to continue logging – this is necessary as stated above if you are performing SQL replication.

You can add a line to your /etc/my.cnf file which will only keep these files around as long as necessary. The line is:

Where X is the number of days you’d like to keep them around. I would recommend 10, but this depends on how busy your MySQL server is and how fast these log files grow. Just make sure it is longer than the slowest slave takes to replicate the data from your master.

Just a side note: You know that you should do this anyway, but make sure you back up your mysql database. The binary log can be used to recover the database in certain situations; so having a backup ensures that if your database server does crash, you will be able to recover the data.