-1

I tried to connect to a local MongoDB instance, but it failed with error message Failed to connect.

I have run the commands shown in the below screenshots. The error message is shown there, too.

My folder structure is:

  • D:/mongodb/bin
  • D:/mongodb/data/db
  • D:/mongodb/log

I am using 32-bit Windows7.

enter image description here

stj
  • 9,037
  • 19
  • 33
mtahir08
  • 87
  • 7

1 Answers1

1

Your data directory doesn't exist where MongoDB is expecting it to be.

For simplicity you can create D:/data/db, which is the default location and where mongod is looking at the moment, and use this as your data directory.

Alternatively if you want to use D:/mongodb/data/db as the data directory you'll need to specify the dbPath when starting mongod

mongod --dbpath D:/mongodb/data/db

This can also be done in a configuration file.

sheilak
  • 5,833
  • 7
  • 34
  • 43