mysql dba系統學習(17)mysql的備份和恢複的完整實踐

來源:互聯網
上載者:User

mysql的備份和恢複的完整實踐

一,備份資料庫之間的環境設定

1,建立資料庫test1,建立表tt插入如下資料

mysql> create  database test1;Query OK, 1 row affected (0.04 sec)mysql> use test1Database changedmysql> create table tt(id int,name varchar(100),msg varchar(200)) engine=myisam;Query OK, 0 rows affected (0.18 sec)mysql> insert into tt values(1,'chenzhongyang','how are you');Query OK, 1 row affected (0.00 sec)mysql> insert into tt values(2,'tianhongyan','BMW');Query OK, 1 row affected (0.00 sec)mysql> insert into tt values(3,'jisuanji','why');Query OK, 1 row affected (0.00 sec)

2,由於我設定的二進位記錄檔的記錄格式是row,所以每一行的資料改變就會記錄一次日誌

mysql>showvariableslike"%format%"

->;

+---------------------+-------------------+

|Variable_name|Value|

+---------------------+-------------------+

|binlog_format|ROW|

3,此時只有一個二進位記錄檔

mysql>showbinarylogs;

+-----------------+-----------+

|Log_name|File_size|

+-----------------+-----------+

|mysqlbin.000161|1133|

+-----------------+-----------+

1rowinset(0.00sec)

4,查看二進位記錄檔的內容

二進位記錄檔end_log_pos1133

[root@test4 ~]# mysqlbinlog '/tmp/mysqlbin.000161'。。。。。。。。。。。。。。。。。。。# at 588#130905 22:26:42 server id 1  end_log_pos 658   Query   thread_id=7 exec_time=0 error_code=0SET TIMESTAMP=1378391202/*!*/;COMMIT/*!*/;# at 658#130905 22:27:15 server id 1  end_log_pos 727   Query   thread_id=7 exec_time=0 error_code=0SET TIMESTAMP=1378391235/*!*/;BEGIN/*!*/;# at 727# at 775#130905 22:27:15 server id 1  end_log_pos 775   Table_map: `test1`.`tt` mapped to number 21#130905 22:27:15 server id 1  end_log_pos 827   Write_rows: table id 21 flags: STMT_END_FBINLOG 'w5QoUhMBAAAAMAAAAAcDAAAAABUAAAAAAAEABXRlc3QxAAJ0dAADAw8PBCwBWAIHw5QoUhcBAAAANAAAADsDAAAAABUAAAAAAAEAA//4AgAAAAsAdGlhbmhvbmd5YW4DAEJNVw=='/*!*/;# at 827#130905 22:27:15 server id 1  end_log_pos 897   Query   thread_id=7 exec_time=0 error_code=0SET TIMESTAMP=1378391235/*!*/;COMMIT/*!*/;# at 897#130905 22:27:56 server id 1  end_log_pos 966   Query   thread_id=7 exec_time=0 error_code=0SET TIMESTAMP=1378391276/*!*/;BEGIN/*!*/;# at 966# at 1014#130905 22:27:56 server id 1  end_log_pos 1014  Table_map: `test1`.`tt` mapped to number 21#130905 22:27:56 server id 1  end_log_pos 1063  Write_rows: table id 21 flags: STMT_END_FBINLOG '7JQoUhMBAAAAMAAAAPYDAAAAABUAAAAAAAEABXRlc3QxAAJ0dAADAw8PBCwBWAIH7JQoUhcBAAAAMQAAACcEAAAAABUAAAAAAAEAA//4AwAAAAgAamlzdWFuamkDAHdoeQ=='/*!*/;# at 1063#130905 22:27:56 server id 1  end_log_pos 1133  Query   thread_id=7 exec_time=0 error_code=0SET TIMESTAMP=1378391276/*!*/;COMMIT/*!*/;DELIMITER ;# End of log fileROLLBACK /* added by mysqlbinlog */;/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.