乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      mysqldump mysqlbinlog恢復(fù)測(cè)試 | 惜分飛

       面包小屋 2013-12-11

      mysqldump+mysqlbinlog恢復(fù)測(cè)試

      鏈接:http://www./1232.html

      標(biāo)題:mysqldump+mysqlbinlog恢復(fù)測(cè)試

      作者:惜分飛?版權(quán)所有[文章允許轉(zhuǎn)載,但必須以鏈接方式注明源地址,否則追究法律責(zé)任.]

      一、模擬環(huán)境
      mysql> create database test;
      Query OK, 1 row affected (0.02 sec)

      mysql> use test;
      Database changed
      mysql> reset master;
      Query OK, 0 rows affected (0.04 sec)

      mysql> show binary logs;
      +—————–+———–+
      | Log_name | File_size |
      +—————–+———–+
      | mysqlbin.000001 | 107 |
      +—————–+———–+
      1 row in set (0.00 sec)

      mysql> create table t(id int,name varchar(10));
      Query OK, 0 rows affected (0.09 sec)

      mysql> insert into t values(1,’aaaa’);
      Query OK, 1 row affected (0.01 sec)

      mysql> insert into t values(2,’bbbb’);
      Query OK, 1 row affected (0.00 sec)

      二、使用mysqldump備份數(shù)據(jù)
      mysqldump -u root -ppassw0rd –skip-opt –extended-insert=false –master-data=2 –single-transaction –allow-keywords –add-locks –add-drop-table -F -q test >/tmp/test.sql

      三、繼續(xù)操作
      mysql> insert into t values(3,’cccc’);
      ERROR 2006 (HY000): MySQL server has gone away
      No connection. Trying to reconnect…
      Connection id: 208
      Current database: test

      Query OK, 1 row affected (0.00 sec)

      mysql> insert into t values(4,’dddd’);
      Query OK, 1 row affected (0.00 sec)

      mysql> drop table t;
      Query OK, 0 rows affected (0.04 sec)

      mysql> create table t1 as
      -> select * from information_schema.tables;
      Query OK, 79 rows affected (0.27 sec)
      Records: 79 Duplicates: 0 Warnings: 0

      四、報(bào)告誤刪除表,開(kāi)始恢復(fù)準(zhǔn)備
      mysql> show binary logs;
      +—————–+———–+
      | Log_name | File_size |
      +—————–+———–+
      | mysqlbin.000001 | 605 |
      | mysqlbin.000002 | 14686 |
      +—————–+———–+
      2 rows in set (0.00 sec)

      tee /tmp/output.txt
      Logging to file ‘/tmp/output.txt’
      mysql> show binlog events in ‘mysqlbin.000002′;
      ……………………省略
      mysql> notee
      Outfile disabled.
      mysql> exit
      Bye

      查找刪除表的位置(起點(diǎn)和終點(diǎn))
      [root@ECP-UC-DB1 tmp]# cat output.txt |grep “DROP TABLE”
      | mysqlbin.000002 | 461 | Query | 1 | 564 | use `test`; DROP TABLE `t` /* generated by server */
      [root@ECP-UC-DB1 mysqllog]# cat /tmp/test.sql |grep MASTER
      – CHANGE MASTER TO MASTER_LOG_FILE=’mysqlbin.000002′, MASTER_LOG_POS=107;

      生成恢復(fù)sql語(yǔ)句
      mysqlbinlog –start-position=107 –stop-position=461 mysqlbin.000002>/tmp/drop.sql
      mysqlbinlog –start-position=564 mysqlbin.000002>>/tmp/drop.sql

      五、開(kāi)始恢復(fù)
      找一個(gè)測(cè)試庫(kù),拷貝/tmp/drop.sql和/tmp/test.sql到備庫(kù),然后進(jìn)行恢復(fù)
      mysql> create database test;
      Query OK, 1 row affected (0.00 sec)
      mysql> use test;
      Database changed
      mysql> source /tmp/test.sql
      mysql> source /tmp/drop.sql

      六、測(cè)試恢復(fù)結(jié)果
      mysql> show tables;
      +—————-+
      | Tables_in_test |
      +—————-+
      | t |
      | t1 |
      +—————-+
      2 rows in set (0.00 sec)

      mysql> select * from t;
      +——+——+
      | id | name |
      +——+——+
      | 1 | aaaa |
      | 2 | bbbb |
      | 3 | cccc |
      | 4 | dddd |
      +——+——+
      4 rows in set (0.00 sec)

      mysql> select count(*) from t1;
      +———-+
      | count(*) |
      +———-+
      | 79 |
      +———-+
      1 row in set (0.02 sec)

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶(hù) 評(píng)論公約

        類(lèi)似文章 更多