9
votes

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
5
You have to create that folders on c:red_alert

5 Answers

24
votes

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

3
votes

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

mongod.exe --dbpath E:\workspace\mongodb\data
2
votes

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

2
votes

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.

1
votes

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.