Explore Courses Blog Tutorials Interview Questions
0 votes
in Web Technology by (47.6k points)

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.

2 Answers

0 votes
by (106k points)

If you want to do it in the simplest steps without doing much work then you can use mongodump, and it's faster:

mongodump -d <database_name> -o <directory_backup>

And for restoring/importing it you can use the below-mentioned command:-

mongorestore -d <database_name> <directory_backup>

0 votes
by (108k points)

First of all, you have to make sure that you have to connect to your MongoDB in command prompt and you can connect to your mongoDB localhost.

After that just open a new command prompt and perform the following syntax:

mongodump -d database_name -o directory_to_store_dumps

If you want to learn more about MongoDB then go through this MongoDB course for more insights.


Related questions

Browse Categories