zoukankan      html  css  js  c++  java
  • mysqlbinlog工具的作用是什么呢,如何将binary log转换为文本格式?

    需求描述:

      今天在看mysqlbinlog这个工具,就在想这个工具到底是干嘛的呢,在mysql数据库中,

      binary log中记录了数据库内容的变化或者说修改,这些修改是以二进制的方式存储到

      binary log中的,那么要想将二进制格式转换成为文本格式,即通过文本格式显示

    操作过程:

    1.直接通过mysqlbinlog工具,将binary log以文本格式显示

    mysqlbinlog mysql-bin.000031 > /tmp/mysql-bin.000031.txt

    备注:将mysql-bin日志进行解析,并且将输出存放在txt文件中

    2.查看生成的txt文件

    [mysql@redhat6 data]$ more /tmp/mysql-bin.000031.txt
    /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
    /*!40019 SET @@session.max_insert_delayed_threads=0*/;
    /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
    DELIMITER /*!*/;
    # at 4
    #180411  9:32:38 server id 1  end_log_pos 107     Start: binlog v 4, server v 5.5.57-log created 180411  9:32:38 at startup
    ROLLBACK/*!*/;
    BINLOG '
    tmXNWg8BAAAAZwAAAGsAAAAAAAQANS41LjU3LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAC2Zc1aEzgNAAgAEgAEBAQEEgAAVAAEGggAAAAICAgCAA==
    '/*!*/;
    # at 107
    #180411  9:48:56 server id 1  end_log_pos 220     Query    thread_id=11    exec_time=0    error_code=0
    use `employees`/*!*/;
    SET TIMESTAMP=1523411336/*!*/;
    SET @@session.pseudo_thread_id=11/*!*/;
    SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
    SET @@session.sql_mode=0/*!*/;
    SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
    /*!C utf8 *//*!*/;
    SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=8/*!*/;
    SET @@session.lc_time_names=0/*!*/;
    SET @@session.collation_database=DEFAULT/*!*/;
    DROP TABLE `titles` /* generated by server */
    /*!*/;
    # at 220
    #180411  9:49:01 server id 1  end_log_pos 335     Query    thread_id=11    exec_time=0    error_code=0
    SET TIMESTAMP=1523411341/*!*/;
    DROP TABLE `salaries` /* generated by server */
    /*!*/;
    # at 335
    #180411  9:49:20 server id 1  end_log_pos 408     Query    thread_id=12    exec_time=0    error_code=0
    SET TIMESTAMP=1523411360/*!*/;
    BEGIN
    /*!*/;
    # at 408
    #180411  9:49:20 server id 1  end_log_pos 524     Query    thread_id=12    exec_time=0    error_code=0
    SET TIMESTAMP=1523411360/*!*/;

    备注:其中就记录了时间,binlog的位置.做了操作的SQL语句.

    文档创建时间:2018年4月18日11:13:57

  • 相关阅读:
    CF 256C Furlo and Rublo and Game【博弈论,SG函数】
    opengl笔记——OpenGL好资料备忘
    SQL SERVER 2012/2014 链接到 SQL SERVER 2000的各种坑
    ORACLE数据库对比表结构
    SSRS Reports 2008性能优化案例二
    Linux LVM学习总结——扩展卷组VG
    MySQL备份还原——AutoMySQLBackup介绍
    mysqldump: Got error: 1142: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'accounts' when using LOCK TABLES
    MySQL备份还原——mysqldump工具介绍
    ORACLE查看数据文件包含哪些对象
  • 原文地址:https://www.cnblogs.com/chuanzhang053/p/8872966.html
Copyright © 2011-2022 走看看