9

I am new to mongo, and I am trying to install mongo on my windows system. I am following THIS tutorial, but when I do

 C:\mongodb\bin\mongod.exe

my CMD gives me this output

2015-04-20T18:53:27.433+0500 I STORAGE  [initandlisten] exception in ini
en: 29 Data directory C:\data\db\ not found., terminating
2015-04-20T18:53:27.436+0500 I CONTROL  [initandlisten] dbexit:  rc: 100
Community
  • 1
  • 1
baig772
  • 3,404
  • 11
  • 48
  • 93

5 Answers5

24

MongoDB requires a data directory to store all data. MongoDB’s default data directory path is \data\db.

Create this folder

md \data\db

You can specify an alternate path for data files using the --dbpath option to mongod.exe, for example:

C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data

If your path includes spaces, enclose the entire path in double quotes,

for example:

C:\mongodb\bin\mongod.exe --dbpath "d:\test\mongo db data"

Read more in detail

Akshay Vijay Jain
  • 13,461
  • 8
  • 60
  • 73
Braj
  • 46,415
  • 5
  • 60
  • 76
  • I am using version 3.6, could not find mongod.conf to put the configurations, so I have to type "monog --dbpath path" everytime, therefore created a batch file for same to get it quickly, could not find any help how to make configuration changes in mongo 3.6 – Akshay Vijay Jain Jan 15 '18 at 06:49
3

I fixed the same using :

Create a folder data in

D:\project-workspace\mongodb\data

Then Create another folder db inside data ie,

D:\project-workspace\mongodb\data\db

Then run the command

mongod --dbpath D:\project-workspace\mongodb\data\db

Make sure you have set environment variable for mongodb else browse

C:\Program Files\MongoDB\Server\3.4\bin
and then execute this =>
mongod.exe --dbpath E:\workspace\mongodb\data
Jason
  • 661
  • 5
  • 17
2

I also faced the similar problem on windows, moreover, i dont have my environment variable set so i have to go to bin folder and run mongo. Below are the steps i followed 1) I created a folder on my desktop something like "C:\Desktop\data\" 2) In order to use mongo shell, you need to run mongo which is similar to a daemon on unix, so in windows, we can do it by opening a command prompt window and change directory to mongo\bin and run mongod --dbpath C:\Desktop\data and left it runnning 3) I opened second command prompt window, did a change directory to C:\mongo\bin and executed mongod, that's it

Prashanth
  • 91
  • 6
2

Because MongoDB does not know the directory DB.

Fixed Work for me.

Step 1: New Folder e.g. Run cmd

mkdir  E:\workspace\mongodb\data

Step 2: Move to Root MongoDB path e.g. (cd .../MongoDB/.../bin/)

C:\Program Files\MongoDB\Server\3.4\bin>mongod.exe --dbpath E:\workspace\mongodb\data

Ok.

bamossza
  • 3,676
  • 1
  • 29
  • 28
1

Also faced the same issue in windows. if --dbpath directory path does not contain spaces, do not include quotes. Removing quotes, when the path does not have space, resolved the issue.

Kalyan
  • 11
  • 1