Explore Courses Blog Tutorials Interview Questions
0 votes
in Web Technology by (50.2k points)
I want to import my database which is stored in .bson file using the mongorestore command. But when I am implementing it, it is not working. Can somebody advise me on the correct format of the mongorestore and the other basic tools for restoring the database?

1 Answer

0 votes
by (108k points)

For importing the .bson file in MongoDB, just type the following onto the mongo shell:

mongorestore -d db_name -c collection_name /path/file.bson

If there is only a single collection then refer the following code:

mongorestore --drop -d db_name -c collection_name /path/file.bson

And regarding the restoring procedure for the whole folder that is being exported by mongodump, refer the following code:

mongorestore -d db_name /path/

Browse Categories