mysql的資料匯出方法2

來源:互聯網
上載者:User

標籤:

首先,使用mysqldump命令的前提是,在Cmd中進入mysql安裝目錄下的bin目錄下,才可以使用該命令。
我的mysql安裝在E:盤,所以,首先進入bin目錄下:
E:/Program Files/MySQL/MySQL Server 5.0/bin>
然後,你就可以使用該命令了。


 

1、匯出整個資料庫

mysqldump -u 使用者名稱 -p 資料庫名 > 存放位置

比如:
mysqldump -u root -p project > c:/a.sql 

       (匯出project資料庫已經經過親自測試,成功!)



 

2.匯出一個表的結構,並且帶表中的資料

mysqldump -u 使用者名稱 -p  資料庫名  表名 > 匯出的檔案名稱

mysqldump -u root -p project  position > c:/a.sql 

       (測試,成功!)

 

只匯出表結構,不帶表中的資料:

mysqldump  -d  -u root -p project  position > c:/a.sql 

       (測試,成功!)

 

3.匯出一個資料庫結構

mysqldump -u wcnc -p -d --add-drop-table smgp_apps_wcnc >d:wcnc_db.sql
-d 沒有資料 --add-drop-table 在每個create語句之前增加一個drop table

 

4.匯入資料庫

常用source 命令
進入mysql資料庫控制台,
d:/program files/mysql/mysql server 5.1/bin > mysql -u root -p
d:/program files/mysql/mysql server 5.1/bin > mysql>use ‘資料庫‘
然後使用source命令,後面參數為指令檔(如這裡用到的.sql)
d:/program files/mysql/mysql server 5.1/bin > mysql>source d:wcnc_db.sql


5.遠程匯出資料庫

命令如下:

mysqldump -h  192.168.11.210  -u  root  -p  test>c:/test.sql

mysql的資料匯出方法2

聯繫我們

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