mongodb 學習筆記 07 -- 資料備份、恢複

來源:互聯網
上載者:User

標籤:mongodb   nosql   

  • mongoexport 匯出json或者csv格式
  • mongoimport 匯入json或者csv
  • mongodump 匯出二進位bson結構資料以及索引資訊
  • mongorestore 匯入二進位檔案

mongoexport

-h 主機--port 連接埠號碼-u 使用者名稱-p 密碼-d 庫名-c 表名-f field1,field..... 匯出的欄位-q 查詢條件 -o 匯出檔案名稱--csv 等同於 --type=csv 匯出csv格式,一定要指定-f 匯出欄位才能匯出csv

例子: 把test資料庫中my表 中的my_id<200的_id跟username 匯出成csv格式

 mongoexport -u test -p 64823723zk -d test -c my -q {my_id:{‘$lt‘:200}} --type=csv -f _id,username,a -o my.csv

mongoimport

-d 匯入的資料庫-c 匯入的表--type csv/json--file 檔案路徑

例子: 向test資料庫中stu表中匯入stu.json 中的資料

 mongoimport -u test -p 123 -d test -c stu --type json --file ./stu.json

mongodump

-d 庫名-c 表名-o 匯出路徑-f field1,field..... 欄位名

例子: 把test資料庫的my表匯出二進位bson結構資料以及索引資訊儲存到dump目錄下
./mongodump -u test -p 123 -d test -c my -o ./dump

mongorestore

-d 資料庫--dir=  bson跟索引資訊存放的目錄

例子:

mongorestore -u test -p 123 -d test --dir=./dump/test/

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

mongodb 學習筆記 07 -- 資料備份、恢複

相關文章

聯繫我們

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