Restore mongo collection with bson file

I’ve exported the database on the server using mongodump command and dump is stored in .bson file. I need to import that in my local server using mongorestore command.

It’s very simple to import a .bson file:

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

Incase only for a single collection. Try this:

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

For restoring the complete folder exported by mongodump:

mongorestore -d db_name /path/

Leave a Reply

Your email address will not be published. Required fields are marked *