How do I restore a database using MongoDB 5.0 CLI?

All we need is an easy explanation of the problem, so here it is.

I’ve just installed the MongoDB version 5.0 CLI tools on my workstation.

But now when I go to restore a database like I’ve always done I get an error:

mongorestore
mongorestore : The term 'mongorestore' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
At line:1 char:1
+ mongorestore
+ ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (mongorestore:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

If I list the MongoDB 5.0 bin directory this is what I see:

 Directory: D:\MongoDB\Server\5.0\bin


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         7/19/2021  10:45 PM           1558 InstallCompass.ps1
-a----         7/19/2021  11:10 PM       22162432 mongo.exe
-a----         7/13/2021   2:24 PM       13275648 mongocli.exe
-a----         7/26/2021   5:02 PM            577 mongod.cfg
-a----         7/20/2021  12:14 AM       46752256 mongod.exe
-a----         7/20/2021  12:14 AM      528224256 mongod.pdb
-a----         7/19/2021  11:35 PM       29746688 mongos.exe
-a----         7/19/2021  11:35 PM      311988224 mongos.pdb

I’m using Windows 10. What happened to my trusty mongorestore and mongoimport commands? They are no longer available under version 5. How can I restore a database under MongoDB version 5.0.1?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Excerpt from – https://docs.mongodb.com/database-tools/

Starting with MongoDB 4.4, the MongoDB Database Tools are now released separately from the MongoDB Server and use their own versioning, with an initial version of 100.0.0.

Previously, these tools were released alongside the MongoDB Server and used matching versioning.

Here’s the link to download –
https://www.mongodb.com/try/download/database-tools

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply