Mysql系列学习四(mysql二进制log文件切换) 发布日期:2017-03-02 21:34:51     博主推荐★

1,查看是否打开二进制日志文件的功能

 mysql> show  variables like "%log_bin%";
+---------------------------------+-------+
| Variable_name                   | Value |
+---------------------------------+-------+
| log_bin                         | ON    |
| log_bin_trust_function_creators | OFF   |
| log_bin_trust_routine_creators  | OFF   |
| sql_log_bin                     | ON    |
+---------------------------------+-------+


2,查看二进制文件的情况

mysql> show master logs;
+----------+-----------+
| Log_name | File_size |
+----------+-----------+
| 1.000001 |       141 |
| 1.000002 |       106 |
+----------+-----------+
2 rows in set (0.00 sec)

mysql> show binary logs;
+----------+-----------+
| Log_name | File_size |
+----------+-----------+
| 1.000001 |       141 |
| 1.000002 |       106 |
+----------+-----------+
2 rows in set (0.00 sec)

3,切换二进制文件

mysql> flush logs;
Query OK, 0 rows affected (0.02 sec)

mysql> show binary logs;
+----------+-----------+
| Log_name | File_size |
+----------+-----------+
| 1.000001 |       141 |
| 1.000002 |       141 |
| 1.000003 |       106 |
+----------+-----------+
3 rows in set (0.01 sec)

4,删除或者初始化二进制文件

mysql> reset master;
Query OK, 0 rows affected (0.03 sec)

mysql> show binary logs;
+----------+-----------+
| Log_name | File_size |
+----------+-----------+
| 1.000001 |       106 |
+----------+-----------+
1 row in set (0.00 sec)

5,删除指定的二进制文件

mysql> purge binary logs to '1.000003'; 删除二进制文件1.000001和1.000002

Query OK, 0 rows affected (0.48 sec)

mysql> show binary logs;
+----------+-----------+
| Log_name | File_size |
+----------+-----------+
| 1.000003 |       141 |
| 1.000004 |       141 |
| 1.000005 |       141 |
| 1.000006 |       141 |
| 1.000007 |       141 |
| 1.000008 |       106 |
+----------+-----------+

6,指定二进制日志失效期

mysql> show variables like "%expire%";
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| expire_logs_days | 0     |
+------------------+-------+
1 row in set (0.01 sec)

mysql> set global  expire_logs_days=5;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like "%expire%";
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| expire_logs_days | 5     |
+------------------+-------+
1 row in set (0.00 sec)


博文地址:https://blog.ahamu.cn/blog/detail.html?id=112
   
推荐文章
  • 1
    sysbench
    2020/07/08
  • 2
    phper转java记录篇-spring boot
    2020/06/10
  • 3
    thinkphp5.0使用路由之后,post请求的
    2020/05/19
  • 4
    springboot单元测试aop失效
    2020/05/15
  • 5
    脑海中的JVM
    2020/05/12
  • 6
    IDEA搜索插件时显示search results
    2020/05/12
  • 7
    spring boot 配置加载源码查找
    2020/04/20
  • 8
    通过javap命令分析java汇编指令
    2020/04/16
  • 9
    IDEA小知识:查看JVM内存使用情况的步骤
    2020/04/16
  • 10
    springboot-加载自定义的properti
    2020/04/14
  • 11
    Jenkins执行shell脚本无法启动子进程解决
    2020/04/03
  • 12
    mac idea激活找专业的
    2020/04/02
  • 13
    Jenkins + DockerSwarm 实现弹
    2020/03/31
  • 14
    mac swarm学习过程
    2020/03/31
  • 15
    spring cloud
    2020/03/18
  • 16
    JAVA开发中遇到的问题记录002
    2020/03/12
  • 17
    JAVA开发中遇到的问题记录001
    2020/03/07
  • 18
    php -i查看信息
    2020/02/23
  • 19
    phpStorm中使用xdebug工具调试dock
    2019/12/09
  • 20
    讲的比较好的B+树执行原理的文章
    2019/12/09
最喜标签
NYOJ 面试 AJAX ping CentOS 灰度算法 YII2