MYSQL備份資料庫和還原資料庫操作

來源:互聯網
上載者:User

標籤:mysql 備份   資料庫   還原

備份資料庫:

伺服器1:192.168.26.210

mysqldump -uroot -p -h127.0.0.1 --all-databases  --flush-logs --master-data=2 --lock-all-tables >all.sql

650) this.width=650;" src="http://s1.51cto.com/wyfs02/M00/8C/2C/wKiom1hkYDPgTknWAADJWbh9uT8153.png-wh_500x0-wm_3-wmp_4-s_483847755.png" title="1.png" alt="wKiom1hkYDPgTknWAADJWbh9uT8153.png-wh_50" />

把資料複製到其它伺服器(192.168.26.212)上:

在伺服器1(192.168.26.210)上執行命令: scp all.sql node3:/data/

650) this.width=650;" src="http://s5.51cto.com/wyfs02/M00/8C/29/wKioL1hkYFixfjdeAAD0Y0--AaA719.png-wh_500x0-wm_3-wmp_4-s_1953992294.png" title="2.png" alt="wKioL1hkYFixfjdeAAD0Y0--AaA719.png-wh_50" />

在伺服器2(192.168.26.212)上查看備份資料並匯入資料:

執行命令:ls

                  mysql -uroot -p -h127.1<all.sql

650) this.width=650;" src="http://s5.51cto.com/wyfs02/M02/8C/29/wKioL1hkYHrR2Q-fAAB1pSJ8iJI952.png-wh_500x0-wm_3-wmp_4-s_1504676549.png" title="3.png" alt="wKioL1hkYHrR2Q-fAAB1pSJ8iJI952.png-wh_50" />

查看匯入資料是否成功:

執行命令:show databases;

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/8C/2C/wKiom1hkYLqRJML_AAC6jzkKsIo929.png-wh_500x0-wm_3-wmp_4-s_3433646293.png" title="4.png" alt="wKiom1hkYLqRJML_AAC6jzkKsIo929.png-wh_50" />

本文出自 “在路上……找回丟失的記憶” 部落格,請務必保留此出處http://jdonghong.blog.51cto.com/3473478/1887144

MYSQL備份資料庫和還原資料庫操作

聯繫我們

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