Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start mongo db on windows

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
like image 768
baig772 Avatar asked Apr 20 '15 13:04

baig772


3 Answers

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

like image 135
Braj Avatar answered Oct 06 '22 00:10

Braj


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
like image 23
Jason Avatar answered Oct 06 '22 01:10

Jason


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.

like image 36
Kalyan Avatar answered Oct 05 '22 23:10

Kalyan