How to "mongorestore" a Database Dump to a Different Database?

If you created a dump of your MongoDB database using the mongodump utility, then you can simply restore it into another database using the mongorestore utility, for example, in the following way:

    --nsFrom "from_db_name.*"
    --nsTo "to_db_name.*"

This would restore all collections in the "from_db_name" database to the "to_db_name" database.

Note the asterisks (*) at the end of the database to/from names. They serve as a wild card for matching all collection names in the database. As a result, all database collections are restored from the "from_db_name" database to the "to_db_name" database.

Hope you found this post useful. It was published . Please show your love and support by sharing this post.