mongodb中有多個集合,我只能利用mongoexport一個集合一個集合的匯出。
怎樣可以批量匯出呢,集合的欄位是一樣的。
mongodb匯出txt文本代碼:
mongoexport -h 127.0.0.1 --port 27017 --username username --password password --collection accounts -f account,balance --out 1.txt --db dbname
集合串列:

uj5u.com熱心網友回復:
mongodump不行?uj5u.com熱心網友回復:
但是我想要txt檔案,mongodump只能匯出dmp檔案啊。
uj5u.com熱心網友回復:
拼成這個腳本放到shell檔案里面 直接執行這個shell檔案mongoexport --db test --collection traffic1 --out traffic.json1
mongoexport --db test --collection traffic2 --out traffic.json2
mongoexport --db test --collection traffic3 --out traffic.json3
uj5u.com熱心網友回復:
用pymongo就可以了uj5u.com熱心網友回復:
我在一個MongoDB論壇上看到過有方法可以將查詢結果匯出到文本中,你可以參考:http://forum.foxera.com/mongodb/topic/145/mongodb%E8%BF%90%E7%BB%B4-%E5%AF%BC%E5%87%BA%E6%9F%A5%E8%AF%A2%E7%BB%93%E6%9E%9C%E5%88%B0%E6%96%87%E6%9C%AC%E4%B8%AD?un=Jerry
uj5u.com熱心網友回復:
博主解決了么?我是需要用Spark讀取一個資料庫下的所有collections,表結構和欄位也是一樣的。轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/78246.html
標籤:MongoDB
上一篇:利用binlog實作mysql和posgresql同步
下一篇:DB2 資料庫編目問題反復出現
