美文网首页
mysql 的日志

mysql 的日志

作者: 尘曦的雨 | 来源:发表于2017-09-12 20:56 被阅读14次
    日志:
            查询日志:general_log
            慢查询日志:log_slow_queries
            错误日志:log_error, log_warnings
            二进制日志:binlog
            中继日志:relay_log
            事务日志:innodb_log
            
            1、查询日志
                记录查询语句,日志存储位置:
                    文件:file
                    表:table (mysql.general_log)
                    
                general_log={ON|OFF}
                general_log_file=HOSTNAME.log 
                log_output={FILE|TABLE|NONE}
                
            2、慢查询日志
                慢查询:运行时间超出指定时长的查询;
                    long_query_time
                存储位置:
                    文件:FILE
                    表:TABLE,mysql.slog_log
                    
                log_slow_queries={ON|OFF}
                slow_query_log={ON|OFF}
                slow_query_log_file=
                log_output={FILE|TABLE|NONE}
                log_slow_filter=admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
                log_slow_rate_limit
                log_slow_verbosity
                
            3、错误日志
                记录如下几类信息:
                    (1) mysqld启动和关闭过程中输出的信息; 
                    (2) mysqld运行中产生的错误信息; 
                    (3) event scheduler运行时产生的信息;
                    (4) 主从复制架构中,从服务器复制线程启动时产生的日志;
                    
                log_error=
                    /var/log/mariadb/mariadb.log|OFF
                log_warnings={ON|OFF}
                
            4、二进制日志
                用于记录引起数据改变或存在引起数据改变的潜在可能性的语句(STATEMENT)或改变后的结果(ROW),也可能是二者混合;
                功用:“重放”
                
                binlog_format={STATEMENT|ROW|MIXED}
                    STATEMENT:语句;
                    ROW:行;
                    MIXED:混编;
                    
                查看二进制日志文件列表:
                     SHOW MASTER|BINARY LOGS;
                     
                查看当前正在使用的二进制日志文件:
                    SHOW MASTER STATUS;
                    
                查看二进制 日志文件中的事件:
                    SHOW BINLOG EVENTS   [IN 'log_name'] [FROM pos] [LIMIT [offset,] row_count]
                    
                服务器变量:
                    log_bin=/PATH/TO/BIN_LOG_FILE
                        只读变量;
                    session.sql_log_bin={ON|OFF}
                        控制某会话中的“写”操作语句是否会被记录于日志文件中;
                    max_binlog_size=1073741824
                    sync_binlog={1|0}
                    
                mysqlbinlog:
                        YYYY-MM-DD hh:mm:ss
                    
                     --start-datetime=
                     --stop-datetime=
                     
                     -j, --start-position=#
                      --stop-position=#
                      
                      --user, --host, --password
    
        在mysql数据库里有一张表专门用来保存查询日志的
    MariaDB [mysql]> show tables;
    +---------------------------+
    | Tables_in_mysql           |
    +---------------------------+
    | columns_priv              |
    | db                        |
    | event                     |
    | func                      |
    | general_log               |   保存查询日志的表
    | help_category             |
    | help_keyword              |
    | help_relation             |
    | help_topic                |
    | host                      |
    | ndb_binlog_index          |
    | plugin                    |
    | proc                      |
    | procs_priv                |
    | proxies_priv              |
    | servers                   |
    | slow_log                  |
    | tables_priv               |
    | time_zone                 |
    | time_zone_leap_second     |
    | time_zone_name            |
    | time_zone_transition      |
    | time_zone_transition_type |
    | user                      |
    +---------------------------+
    24 rows in set (0.04 sec)
    查询日志如何启用他们,通过修改服务器变量
     查看服务器全局变量关于查询日志的变量
    MariaDB [mysql]> show global variables like 'general%';
    +------------------+-------------+
    | Variable_name    | Value       |
    +------------------+-------------+
    | general_log      | OFF         |  默认是关闭的,生产中也建议关闭
    | general_log_file | centos7.log |
    +------------------+-------------+
    2 rows in set (0.01 sec)
    MariaDB [mysql]> show global variables like 'log_output';  
    +---------------+-------+
    | Variable_name | Value |
    +---------------+-------+
    | log_output    | FILE  |  定义日志输出到何处
    +---------------+-------+
    1 row in set (0.01 sec)
    MariaDB [mysql]> set global general_log=ON;  打开查询日志的;次变量是全局变量
    Query OK, 0 rows affected (0.00 sec)
    
    MariaDB [mysql]> show global variables like 'general%';  查看是否打开
    +------------------+-------------+
    | Variable_name    | Value       |
    +------------------+-------------+
    | general_log      | ON          |  查询日志已经打开
    | general_log_file | centos7.log |
    +------------------+-------------+
    2 rows in set (0.00 sec)
    MariaDB [mysql]> select * from mydb.students where stuid=3; 执行一个查询语句查看
    +-------+----------+------+--------+-------------+
    | stuid | name     | age  | gender | major       |
    +-------+----------+------+--------+-------------+
    |     3 | jingtian |   35 | F      | chuiniudafa |
    +-------+----------+------+--------+-------------+
    1 row in set (0.00 sec)
    [root@centos7 ~]# ls /var/lib/mysql/
    aria_log.00000001  centos7.log    生成的查询文件  ib_logfile0  mydb   mysql.sock          test
    aria_log_control   ibdata1      ib_logfile1  mysql  performance_schema
    关闭查询日志
    MariaDB [mysql]> set @@global.general_log=OFF;
    Query OK, 0 rows affected (0.00 sec)、
    慢查询日志的相关设定
    MariaDB [mysql]> show tables;
    +---------------------------+
    | Tables_in_mysql           |
    +---------------------------+
    | columns_priv              |
    | db                        |
    | event                     |
    | func                      |
    | general_log               |
    | help_category             |
    | help_keyword              |
    | help_relation             |
    | help_topic                |
    | host                      |
    | ndb_binlog_index          |
    | plugin                    |
    | proc                      |
    | procs_priv                |
    | proxies_priv              |
    | servers                   |
    | slow_log                  |  慢查询日志记录的表
    | tables_priv               |
    | time_zone                 |
    | time_zone_leap_second     |
    | time_zone_name            |
    | time_zone_transition      |
    | time_zone_transition_type |
    | user                      |
    +---------------------------+
    24 rows in set (0.00 sec)
    查看关于慢查询日志的社定
    
    MariaDB [mysql]> show global variables like '%slow%';
    +---------------------+--------------------------------------------------------------------------------------------------------------+
    | Variable_name       | Value                                                                                                        |
    +---------------------+--------------------------------------------------------------------------------------------------------------+
    | log_slow_filter     | admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk |
    | log_slow_queries    | OFF                                                                                                          |
    | log_slow_rate_limit | 1                                                                                                            |
    | log_slow_verbosity  |                                                                                                              |
    | slow_launch_time    | 2                                                                                                            |
    | slow_query_log      | OFF                                                                                                          |
    | slow_query_log_file | centos7-slow.log                                                                                             |
    +---------------------+--------------------------------------------------------------------------------------------------------------+
    7 rows in set (0.00 sec)
    
    MariaDB [mysql]> set global slow_query_log=ON; 打开慢查询日志功能
    MariaDB [mysql]> set @@global.log_output='FILE'; 设定将main查询日志保存至文件中
    Query OK, 0 rows affected (0.01 sec)
    错误日志的相管的
    MariaDB [mysql]> show global variables like '%error%';
    +--------------------+------------------------------+
    | Variable_name      | Value                        |
    +--------------------+------------------------------+
    | log_error          | /var/log/mariadb/mariadb.log |
    | max_connect_errors | 10                           |
    | max_error_count    | 64                           |
    | slave_skip_errors  | OFF                          |
    +--------------------+------------------------------+
    4 rows in set (0.01 sec)
    
    二进制日志
    
    MariaDB [mysql]> show global variables like 'binlog_format';
    +---------------+-----------+
    | Variable_name | Value     |
    +---------------+-----------+
    | binlog_format | STATEMENT |
    +---------------+-----------+
    1 row in set (0.00 sec)
    
    MariaDB [mysql]> show master logs;  查看跟踪日志
    ERROR 1381 (HY000): You are not using binary logging
    二进制日志不支持启动时修改
    
    [root@centos7 ~]# vim /etc/my.cnf.d/server.cnf  修改文件
    
    #
    # These groups are read by MariaDB server.
    # Use it for options that only the server (but not clients) should see
    #
    # See the examples of server my.cnf files in /usr/share/mysql/
    #
    
    #
    # These groups are read by MariaDB server.
    # Use it for options that only the server (but not clients) should see
    #
    # See the examples of server my.cnf files in /usr/share/mysql/
    #
    
    # this is read by the standalone daemon and embedded servers
    [server]
    
    # this is only for the mysqld standalone daemon
    [mysqld]
    log-bin=master-log  设置启用二进制日志
    # this is only for embedded server
    [embedded]
    
    # This group is only read by MariaDB-5.5 servers.
    # If you use the same .cnf file for MariaDB of different versions,
    # use this group for options that older servers don't understand
    [mysqld-5.5]
    
    # These two groups are only read by MariaDB servers, not by MySQL.
    # If you use the same .cnf file for MySQL and MariaDB,
    # you can put MariaDB-only options here
    [mariadb]
    
    [mariadb-5.5]
    查看上一个事物的结束点
    MariaDB [(none)]>  show master status;
    +-------------------+----------+--------------+------------------+
    | File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
    +-------------------+----------+--------------+------------------+
    | master-log.000001 |      245 |              |                  |
    +-------------------+----------+--------------+------------------+
    MariaDB [mydb]> delete from students where stuid=1980;  删除一条数据是都会引起二进制日志变化
    Query OK, 1 row affected (0.00 sec)
    MariaDB [mydb]>  show master status; 再次查看
    +-------------------+----------+--------------+------------------+
    | File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
    +-------------------+----------+--------------+------------------+
    | master-log.000001 |      440 |              |                  |
    +-------------------+----------+--------------+------------------+
    1 row in set (0.00 sec)
    MariaDB [mydb]> show binlog events;
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    | Log_name          | Pos | Event_type  | Server_id | End_log_pos | Info                                              |
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    | master-log.000001 |   4 | Format_desc |         1 |         245 | Server ver: 5.5.52-MariaDB, Binlog ver: 4         |
    | master-log.000001 | 245 | Query       |         1 |         313 | BEGIN                                             |
    | master-log.000001 | 313 | Query       |         1 |         413 | use `mydb`; delete from students where stuid=1980 |
    | master-log.000001 | 413 | Xid         |         1 |         440 | COMMIT /* xid=18 */                               |
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    4 rows in set (0.00 sec)
    手动滚动二进制日志文件
    MariaDB [mydb]> flush logs;
    Query OK, 0 rows affected (0.04 sec)
    删除一条数据
    MariaDB [mydb]> delete from students where stuid=1987;
    Query OK, 1 row affected (0.03 sec)
    查看是否滚动的二进制日志文件
    MariaDB [mydb]> show master logs;
    +-------------------+-----------+
    | Log_name          | File_size |
    +-------------------+-----------+
    | master-log.000001 |       874 |
    | master-log.000002 |       440 |
    +-------------------+-----------+
    2 rows in set (0.00 sec)
    MariaDB [mydb]> show master status;  查看当前使用的文件
    +-------------------+----------+--------------+------------------+
    | File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |
    +-------------------+----------+--------------+------------------+
    | master-log.000002 |      440 |              |                  |
    +-------------------+----------+--------------+------------------+
    1 row in set (0.00 sec)
    
    MariaDB [mydb]> show binlog events; 默认查看的第一个日志文件
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    | Log_name          | Pos | Event_type  | Server_id | End_log_pos | Info                                              |
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    | master-log.000001 |   4 | Format_desc |         1 |         245 | Server ver: 5.5.52-MariaDB, Binlog ver: 4         |
    | master-log.000001 | 245 | Query       |         1 |         313 | BEGIN                                             |
    | master-log.000001 | 313 | Query       |         1 |         413 | use `mydb`; delete from students where stuid=1980 |
    | master-log.000001 | 413 | Xid         |         1 |         440 | COMMIT /* xid=18 */                               |
    | master-log.000001 | 440 | Query       |         1 |         508 | BEGIN                                             |
    | master-log.000001 | 508 | Query       |         1 |         608 | use `mydb`; delete from students where stuid=1989 |
    | master-log.000001 | 608 | Xid         |         1 |         635 | COMMIT /* xid=23 */                               |
    | master-log.000001 | 635 | Query       |         1 |         703 | BEGIN                                             |
    | master-log.000001 | 703 | Query       |         1 |         803 | use `mydb`; delete from students where stuid=1986 |
    | master-log.000001 | 803 | Xid         |         1 |         830 | COMMIT /* xid=29 */                               |
    | master-log.000001 | 830 | Rotate      |         1 |         874 | master-log.000002;pos=4                           |
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    11 rows in set (0.00 sec)
    MariaDB [mydb]> show binlog events in 'master-log.000002'; 手动指定要查看的文件 
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    | Log_name          | Pos | Event_type  | Server_id | End_log_pos | Info                                              |
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    | master-log.000002 |   4 | Format_desc |         1 |         245 | Server ver: 5.5.52-MariaDB, Binlog ver: 4         |
    | master-log.000002 | 245 | Query       |         1 |         313 | BEGIN                                             |
    | master-log.000002 | 313 | Query       |         1 |         413 | use `mydb`; delete from students where stuid=1987 |
    | master-log.000002 | 413 | Xid         |         1 |         440 | COMMIT /* xid=32 */                               |
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    4 rows in set (0.00 sec)
    MariaDB [mydb]> set @@session.sql_log_bin=OFF;  会话级别临时关闭二进制功能
    Query OK, 0 rows affected (0.01 sec)
    MariaDB [mydb]> delete from students where stuid=1956; 删除一条数据
    Query OK, 1 row affected (0.01 sec)
    
    MariaDB [mydb]> show binlog events in 'master-log.000002'; 查看日志是否被记录
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    | Log_name          | Pos | Event_type  | Server_id | End_log_pos | Info                                              |
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    | master-log.000002 |   4 | Format_desc |         1 |         245 | Server ver: 5.5.52-MariaDB, Binlog ver: 4         |
    | master-log.000002 | 245 | Query       |         1 |         313 | BEGIN                                             |
    | master-log.000002 | 313 | Query       |         1 |         413 | use `mydb`; delete from students where stuid=1987 |
    | master-log.000002 | 413 | Xid         |         1 |         440 | COMMIT /* xid=32 */                               |
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    4 rows in set (0.00 sec)
    
    MariaDB [mydb]> set @@session.sql_log_bin=ON;  会话级别打开该功能
    Query OK, 0 rows affected (0.00 sec)
    MariaDB [mydb]> delete from students where stuid=1957;  再删除一条记录
    Query OK, 1 row affected (0.01 sec)
    
    MariaDB [mydb]> show binlog events in 'master-log.000002'; 二进制日志又被滚动了
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    | Log_name          | Pos | Event_type  | Server_id | End_log_pos | Info                                              |
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    | master-log.000002 |   4 | Format_desc |         1 |         245 | Server ver: 5.5.52-MariaDB, Binlog ver: 4         |
    | master-log.000002 | 245 | Query       |         1 |         313 | BEGIN                                             |
    | master-log.000002 | 313 | Query       |         1 |         413 | use `mydb`; delete from students where stuid=1987 |
    | master-log.000002 | 413 | Xid         |         1 |         440 | COMMIT /* xid=32 */                               |
    | master-log.000002 | 440 | Query       |         1 |         508 | BEGIN                                             |
    | master-log.000002 | 508 | Query       |         1 |         608 | use `mydb`; delete from students where stuid=1957 |
    | master-log.000002 | 608 | Xid         |         1 |         635 | COMMIT /* xid=44 */                               |
    +-------------------+-----+-------------+-----------+-------------+---------------------------------------------------+
    7 rows in set (0.00 sec)
    
    MariaDB [mydb]> show binlog events in 'master-log.000002'  from 440; 只显示440之后的
    +-------------------+-----+------------+-----------+-------------+---------------------------------------------------+
    | Log_name          | Pos | Event_type | Server_id | End_log_pos | Info                                              |
    +-------------------+-----+------------+-----------+-------------+---------------------------------------------------+
    | master-log.000002 | 440 | Query      |         1 |         508 | BEGIN                                             |
    | master-log.000002 | 508 | Query      |         1 |         608 | use `mydb`; delete from students where stuid=1957 |
    | master-log.000002 | 608 | Xid        |         1 |         635 | COMMIT /* xid=44 */                               |
    +-------------------+-----+------------+-----------+-------------+---------------------------------------------------+
    3 rows in set (0.00 sec)
    MariaDB [mydb]> show binlog events in 'master-log.000002'  from 440 limit 1;  表示只显示440的一行
    +-------------------+-----+------------+-----------+-------------+-------+
    | Log_name          | Pos | Event_type | Server_id | End_log_pos | Info  |
    +-------------------+-----+------------+-----------+-------------+-------+
    | master-log.000002 | 440 | Query      |         1 |         508 | BEGIN |
    +-------------------+-----+------------+-----------+-------------+-------+
    1 row in set (0.00 sec)
    [root@centos7 mysql]# mysqlbinlog master-log.000002  在文件级别查看
    /*!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
    #170912 19:55:00 server id 1  end_log_pos 245   Start: binlog v 4, server v 5.5.52-MariaDB created 170912 19:55:00
    # Warning: this binlog is either in use or was not closed properly.
    BINLOG '
    FMu3WQ8BAAAA8QAAAPUAAAABAAQANS41LjUyLU1hcmlhREIAbG9nAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAA2QAEGggAAAAICAgCAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAeBDn0A==
    '/*!*/;
    # at 245
    #170912 19:55:06 server id 1  end_log_pos 313   Query   thread_id=2 exec_time=0 error_code=0
    SET TIMESTAMP=1505217306/*!*/;
    SET @@session.pseudo_thread_id=2/*!*/;
    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/*!*/;
    BEGIN
    /*!*/;
    # at 313
    #170912 19:55:06 server id 1  end_log_pos 413   Query   thread_id=2 exec_time=0 error_code=0
    use `mydb`/*!*/;
    SET TIMESTAMP=1505217306/*!*/;
    delete from students where stuid=1987
    /*!*/;
    # at 413
    #170912 19:55:06 server id 1  end_log_pos 440   Xid = 32
    COMMIT/*!*/;
    # at 440
    #170912 20:24:56 server id 1  end_log_pos 508   Query   thread_id=2 exec_time=0 error_code=0
    SET TIMESTAMP=1505219096/*!*/;
    BEGIN
    /*!*/;
    # at 508
    #170912 20:24:56 server id 1  end_log_pos 608   Query   thread_id=2 exec_time=0 error_code=0
    SET TIMESTAMP=1505219096/*!*/;
    delete from students where stuid=1957
    /*!*/;
    # at 608
    #170912 20:24:56 server id 1  end_log_pos 635   Xid = 44
    COMMIT/*!*/;
    DELIMITER ;
    # End of log file
    ROLLBACK /* added by mysqlbinlog */;
    /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
    /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
    
    二进制日志事件格式:
                    # at 553
                    #160831  9:56:08 server id 1  end_log_pos 624   Query   thread_id=2     exec_time=0     error_code=0
                    SET TIMESTAMP=1472608568/*!*/;
                    BEGIN
                    /*!*/;
                    
                    事件的起始位置:# at 553
                    事件发生的日期时间:#160831  9:56:08
                    事件发生的服务器id:server id 1
                    事件的结束位置:end_log_pos 624
                    事件的类型:Query
                    事件发生时所在服务器执行此事件的线程的ID: thread_id=2 
                    语句的时间戳与将其写入二进制日志文件中的时间差:exec_time=0
                    错误代码:error_code=0
                    设定事件发生时的时间戳:SET TIMESTAMP=1472608568/*!*/;
                    事件内容:BEGIN
    
    [root@centos7 mysql]# mysqlbinlog --start-position=440 master-log.000002   表示从440以后显示
    /*!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
    #170912 19:55:00 server id 1  end_log_pos 245   Start: binlog v 4, server v 5.5.52-MariaDB created 1
    70912 19:55:00# Warning: this binlog is either in use or was not closed properly.
    BINLOG '
    FMu3WQ8BAAAA8QAAAPUAAAABAAQANS41LjUyLU1hcmlhREIAbG9nAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAA2QAEGggAAAAICAgCAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAeBDn0A==
    '/*!*/;
    # at 440
    #170912 20:24:56 server id 1  end_log_pos 508   Query   thread_id=2 exec_time=0 error_code=0
    SET TIMESTAMP=1505219096/*!*/;
    SET @@session.pseudo_thread_id=2/*!*/;
    SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@sessi
    on.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/*!*/;
    BEGIN
    /*!*/;
    # at 508
    #170912 20:24:56 server id 1  end_log_pos 608   Query   thread_id=2 exec_time=0 error_code=0
    use `mydb`/*!*/;
    SET TIMESTAMP=1505219096/*!*/;
    delete from students where stuid=1957
    /*!*/;
    # at 608
    #170912 20:24:56 server id 1  end_log_pos 635   Xid = 44
    COMMIT/*!*/;
    DELIMITER ;
    # End of log file
    ROLLBACK /* added by mysqlbinlog */;
    /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
    /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
    
    [root@centos7 mysql]# mysqlbinlog --start-position=440 --stop-position=508 master-log.000002   表示查看440-508这一段的数据
    /*!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
    #170912 19:55:00 server id 1  end_log_pos 245   Start: binlog v 4, server v 5.5.52-MariaDB created 1
    70912 19:55:00# Warning: this binlog is either in use or was not closed properly.
    BINLOG '
    FMu3WQ8BAAAA8QAAAPUAAAABAAQANS41LjUyLU1hcmlhREIAbG9nAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAA2QAEGggAAAAICAgCAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAeBDn0A==
    '/*!*/;
    # at 440
    #170912 20:24:56 server id 1  end_log_pos 508   Query   thread_id=2 exec_time=0 error_code=0
    SET TIMESTAMP=1505219096/*!*/;
    SET @@session.pseudo_thread_id=2/*!*/;
    SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@sessi
    on.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/*!*/;
    BEGIN
    /*!*/;
    DELIMITER ;
    # End of log file
    ROLLBACK /* added by mysqlbinlog */;
    /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
    /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
    
    
    
    
    
    
    
    
    

    相关文章

      网友评论

          本文标题:mysql 的日志

          本文链接:https://www.haomeiwen.com/subject/ugmcsxtx.html