複製MySQL資料庫A到另外一個MySQL資料庫B(僅僅針對innodb資料庫引擎)

來源:互聯網
上載者:User

標籤:blog   http   os   使用   sp   檔案   資料   log   bs   

方案一:(不用太大的變化my.ini檔案)

  1. copy 原資料庫A中的   資料庫(database)  ib_logfile1  ib_logfile0   ibdata1;

  2. 關閉目的資料庫B;

  3.  備份目的資料庫B中的  ib_logfile1  ib_logfile0   ibdata1 三個檔案,防止更改後不能使用資料庫;

  4. 將copy 來的原資料庫A中的  ib_logfile1  ib_logfile0   ibdata1 放置在目的資料庫B相應的位置 ,如果您目的資料庫中的  ib_logfile倆個檔案的大小和copy來的檔案大小一樣,直接粘貼就可以;

  5.  重新啟動資料庫B

方案二:(需要更改my.ini檔案)

  1. copy 原資料庫A中的   資料庫(database)  ib_logfile1  ib_logfile0   ibdata1;

  2. 關閉目的資料庫B;

  3. 如果您目的資料庫B中的ib_logfile倆個檔案的大小和copy來的檔案大小不一樣,備份目的資料庫B中的  ib_logfile1   ib_logfile0   ibdata1 三個檔案,防止更改後不能使用資料庫, 刪除目的資料庫下的  ib_logfile1  ib_logfile0 檔案,更改my.ini 檔案中的innodb_log_file_size 為原資料庫中 ib_logfile1  ib_logfile0 檔案大小eg.     innodb_log_file_size=90M ;

  4.  重啟資料庫B;
     成功後,刪除重啟資料庫B的 ib_logfile1  ib_logfile0 ,將copy 來的 ib_logfile1  ib_logfile0 粘貼過來(或者用copy 來的 ib_logfile1  ib_logfile0 替換現有資料庫B中的 ib_logfile1  ib_logfile0 即可);

  5.  粘貼 資料庫(database)   ibdata1 到相應的位置;
     重新啟動資料庫B

PS:目的就是保證
     1、資料庫(database)  ib_logfile1  ib_logfile0   ibdata1;必須同時複製的,也就是說不能在你複製的過程中還有別的操作來操作你要複製的資料庫。(這樣複製過來的資料可能有crash)

轉自:http://my.oschina.net/u/1462678/blog/223646

複製MySQL資料庫A到另外一個MySQL資料庫B(僅僅針對innodb資料庫引擎)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.