How to restore database using mongodb compass?

Viewed 5044

I have a mongodb database in a dump folder which contain some bson and json files. I want to restore it using mongorestore, but I can't connect to the cluster through mongo shell. So I use mongo compass to connect but I have no clue how to restore it in the mongo compass.

2 Answers

You run mongorestore runs from the system command line, not mongo shell. Use the Command Prompt in Windows or Terminal in OS X / Linux to enter the command and you should be good to go. The connection string will be the same one you used to connect through Compass.

To restore you have to follow these steps carefully:-

1: First check dump type if it is a zip file then extract it.

2: open your cmd prompt and go to the folder where your database XYZ (folder) exists.

mi@sujeet-mishra:~/Downloads/dump$

Inside the dump, there is a folder called XYZ (folder of XYZ database)

Now run the command: mongorestore -db XYZ

mi@sujeet-mishra:~/Downloads/dump$ mongorestore -db XYZ

that's it, now refresh your MongoDB and you will get a DB named XYZ.

Related