Giter Club home page Giter Club logo

mysql's Introduction

mysql

Mysql operation hand book

mysql-bin log文件清理

mysql主从会在主会产生大量如mysql-bin*的log日志文件,这会消耗大量的硬盘空间。在保持MySQL主从复制的功能下有两种解决方法:

  1. 设置日志expire_logs_days

设置日志expire_logs_days
修改MySQL配置文件,设置expire_logs_days,重启MySQL。

vim /etc/my.cnf

expire_logs_days = x //日志自动删除的天数。一般讲x设置的短点,如10
直接在MySQL里设置expire_logs_days,无需重启MySQL(临时重启后回复)。

mysql -u root -p

show binary logs;
show variables like '%log%';
set global expire_logs_days = 10;

  1. 手动清楚bin日志文件。

手动清理bin日志文件(特定的)

mysql -u root -p

purge master logs before date_sub(current_date, interval 50 day); //删除50天前的mysql-bin log日志文件
show master logs; # 查看删除状态

也可以重置master,删除所有bin文件(所有的)

mysql -u root -p

reset master;

备注:
PURGE MASTER LOGS手动删除用法示例

mysql -u root -p

purge master logs to 'mysql-bin.010’; //清除mysql-bin.010日志
purge master logs before '2017-08-28 13:00:00'; //清除2016-02-28 13:00:00前的日志
purge master logs before date_sub(now(), interval 3 day); //清除3天前的bin日志

REF: https://www.jianshu.com/p/b0b31282541f

mysql's People

Contributors

stardock avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.