I want to export all collections in MongoDB by the command:
mongoexport -d dbname -o Mongo.json
The result is:
No collection specified!
The manual says, if you don't specify a collection, all collections will be exported.
However, why doesn't this work?
My MongoDB version is 2.0.6.
解决方案
For lazy people, use mongodump, it's faster:
mongodump -d -o
And to "restore/import" it (from directory_backup/dump/):
mongorestore -d
This way, you don't need to deal with all collections individually. Just specify the database.
Note that I would recommend against using mongodump/mongorestore for big data storages. It is very slow and once you get past 10/20GB of data it can take hours to restore.
博客讨论了在MongoDB中使用命令导出所有集合时遇到的问题,使用mongoexport -d dbname -o Mongo.json命令报错。给出解决方案,对于懒人可使用mongodump,还介绍了恢复/导入的命令,但提醒对于大数据存储不推荐使用,因其速度慢。
440

被折叠的 条评论
为什么被折叠?



