zoukankan      html  css  js  c++  java
  • 二进制回复操作

    环境部署
    开启二进制文件
    cat /etc/my.cnf.d/server.cnf
    [server]
    log_bin=mysql-bin

    第一步查看:
    MariaDB [(none)]> show master status;
    +------------------+----------+--------------+------------------+
    | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
    +------------------+----------+--------------+------------------+
    | mysql-bin.000004 | 342 | | |
    +------------------+----------+--------------+------------------+

    第二步回滚:
    MariaDB [(none)]> flush logs;

    第三步查看:
    MariaDB [(none)]> show master status;
    +------------------+----------+--------------+------------------+
    | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
    +------------------+----------+--------------+------------------+
    | mysql-bin.000005 | 385 | | |
    +------------------+----------+--------------+------------------+

    第四步创建:数据库。表。
    MariaDB [(none)]> create database xiao;
    Query OK, 1 row affected (0.001 sec)

    MariaDB [(none)]> use xiao;
    Database changed
    MariaDB [xiao]> create table students ( id int primary key auto_increment,
    name varchar(20));
    Query OK, 0 rows affected (0.012 sec)

    MariaDB [xiao]> insert into students values (0,'aaa');
    Query OK, 1 row affected (0.004 sec)

    MariaDB [xiao]> insert into students values (0,'bbb');
    Query OK, 1 row affected (0.003 sec)

    MariaDB [xiao]> insert into students values (0,'ccc');
    Query OK, 1 row affected (0.001 sec)


    MariaDB [xiao]> select * from students;
    +----+------+
    | id | name |
    +----+------+
    | 1 | aaa |
    | 2 | bbb |
    | 3 | ccc |
    +----+------+

    第五步:删除一条数据
    MariaDB [xiao]> delete from students where id=2;
    Query OK, 1 row affected (0.013 sec)

    MariaDB [xiao]> select * from students;
    +----+------+
    | id | name |
    +----+------+
    | 1 | aaa |
    | 3 | ccc |
    +----+------+

    第六步:查看回滚数据
    MariaDB [xiao]> show master status;
    +------------------+----------+--------------+------------------+
    | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
    +------------------+----------+--------------+------------------+
    | mysql-bin.000005 | 1622 | | |
    +------------------+----------+--------------+------------------+
    cd /var/lib/mysql
    [root@zxw8 mysql]# mysqlbinlog mysql-bin.000005
    # at 1493
    #190709 2:20:29 server id 1 end_log_pos 1591 CRC32 0xfdd65b71 Querthread_id=9 exec_time=0 error_code=0
    SET TIMESTAMP=1562653229/*!*/;
    delete from students where id=2
    /*!*/;

    第七步:回复数据
    [root@zxw8 mysql]# mysqlbinlog /var/lib/mysql/mysql-bin.000005 --start-position=1107 --stop-position=1451 | mysql -uroot -p123
    ERROR 1062 (23000) at line 46: Duplicate entry '3' for key 'PRIMARY'
    MariaDB [xiao]> select * from students;
    +----+------+
    | id | name |
    +----+------+
    | 1 | aaa |
    | 3 | ccc |
    | 7 | bbb |

    mysqlbinlog --start-datetime="2019-06-08 22:55:13" --stop-datetime="2019-06-08 22:55:13" binlog.0000011 > bin.sql

    执行bin.sql文件还原
    source bin.sql

     

     

  • 相关阅读:
    自己做的关于select工具根据属性进行选择
    ae中栅格数据转为矢量数据
    影像图配准代码实现
    ae中最短路径分析
    AE常见接口之间的关系+常见概念 .
    GIS重要概念与术语(转)
    点线面缓冲分析(转自esri中国社区)
    ae中矢量数据转换成栅格数据
    单例模式
    利用gp自己做的生成缓冲区的代码
  • 原文地址:https://www.cnblogs.com/itzhao/p/11293693.html
Copyright © 2011-2022 走看看