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.