10. mysql 匯入匯出資料庫,mysql匯入匯出

來源:互聯網
上載者:User

10. mysql 匯入匯出資料庫,mysql匯入匯出
linux下匯入、匯出mysql資料庫命令


一、匯出資料庫用mysqldump命令

(註:如果沒有此命令,在mysql的安裝路徑,執行此命令):

1、匯出資料和表結構:
mysqldump -u使用者名稱 -p密碼 資料庫名 > 資料庫名.sql
# mysqldump -uroot -p abc > /'path'/abc.sql

註:敲斷行符號後會提示輸入密碼

2、只匯出表結構
mysqldump -u使用者名稱 -p密碼 -d 資料庫名 > 資料庫名.sql
#mysqldump -uroot -p -d abc > /'path'/abc.sql

註:敲斷行符號後會提示輸入密碼

二、匯入資料庫1、首先建空資料庫
mysql>create database abc;


2、匯入資料庫
方法一:
(1)選擇資料庫
mysql>use abc;
(2)設定資料庫編碼
mysql>set names utf8;
(3)匯入資料(注意sql檔案的路徑)
mysql>source /home/abc/abc.sql;
方法二:
mysql -u使用者名稱 -p密碼 資料庫名 < 資料庫名.sql
#mysql -uabc_f -p abc < abc.sql


註:敲斷行符號後會提示輸入密碼


薦:歡迎提出你的見解和建議。






相關文章

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.