zoukankan      html  css  js  c++  java
  • 【原创】数据库基础之Mysql(3)mysql删除历史binlog

    mysql开启binlog后会在/var/lib/mysql下创建binlog文件,如果手工删除,则下次mysql启动会报错:

    mysqld: File './master-bin.000001' not found (Errcode: 2 - No such file or directory)
    2019-02-16T17:00:08.484461Z 0 [ERROR] Failed to open log (file './master-bin.000001', errno 2)
    2019-02-16T17:00:08.484464Z 0 [ERROR] Could not open log file

    正确的删除方法是:

    mysql> show binary logs;
    +-------------------+------------+
    | Log_name | File_size |
    +-------------------+------------+
    | master-bin.000027 | 43442 |
    | master-bin.000028 | 7573 |
    | master-bin.000029 | 371919 |
    +-------------------+------------+
    29 rows in set (0.00 sec)

    mysql> purge binary logs to 'master-bin.000029';
    Query OK, 0 rows affected, 10 warnings (0.18 sec)

    mysql> show binary logs;
    +-------------------+-----------+
    | Log_name | File_size |
    +-------------------+-----------+
    | master-bin.000029 | 696322 |
    +-------------------+-----------+
    1 row in set (0.00 sec)

    另外也可以在配置文件中配置过期时间

    # vi /etc/mysql/my.cnf
    expire_logs_days = 7

    mysql> reset master;

  • 相关阅读:
    Unix&Linux下常见的性能分析工具介绍
    理解Load Average做好压力测试
    cron 的配置和说明
    原生js模仿下拉刷新功能
    webpack初步了解
    数组的迭代方法
    webpack4
    反思面向对象
    C和lua的互相调用
    对Zookeeper的一些分析
  • 原文地址:https://www.cnblogs.com/barneywill/p/10390004.html
Copyright © 2011-2022 走看看