2

I actually copied above two files in MongoDB's data folder which is default in windows machine (C:\data\db ). But when I start mongo shell and type show dbs, it will not show my database.

Steps I followed is as below.

1. copy the data files to C:\data\db
2. start the MongoDB server by mongod --dbpath C:\data\db
3. start the MongoDB shell by mongo command in command prompt
4. type show DB's command to list the databases

But I am not able to see my databases. Any help would be appreciated.

Thanks, Krishna

1
  • What specific version of MongoDB server and shell are you using (output of db.version() and version() in the mongo shell)? What version of MongoDB are the files you are copying from? Are there any startup messages or warnings from mongod? It would be helpful if you can include some of the startup log information starting from the line including "[initandlisten] options .." through to "[initandlisten] waiting for connections ...". – Stennie Nov 8 '17 at 9:54
0

With MMAPv1 you could copy f.ex. local.* files to some new mongod instance and instance saw those. With wiredTiger, you cannot do it anymore.

0

@Krishna, As you said copy the data files to C:\data\db. This is the location of directories for MongoDB database files.

As per MongoDB BOL Here

c:\data\db
c:\data\log

It's By default location of directories for your database and log files. This path is required during starting of mongod server.

If you want to see a new database in your mongo shell. Then you have to import dump (.json) file through mongoimport.

For example in my place the installation location of MongoDB is

C:\Program Files\MongoDB\Server\3.2\bin  

In Bin Folder you shall see mongod as well as all mongo shell command. I am also attaching the screen shot , for your understanding

enter image description here

Now open the command prompt and set the location such as

 C:\Program Files\MongoDB\Server\3.2\bin

Then import your (.json) dump files through mongoimport command like that

 C:\Program Files\MongoDB\Server\3.2\bin>mongoimport --verbose filelocation of json file

Note :- Here (--verbose) will import all (.json) data files from your dump folder into MongoDB database.

For help of mongoimport you can type on that same windows like

 C:\Program Files\MongoDB\Server\3.2\bin>mongoimport --help

After importing the (.json) database files . Go to your mongo shell command and type the command like

>show dbs

Then you can see all databases which you have import through mongoimport shell command.

For your further ref mongoimport

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.