简体   繁体   中英

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

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

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

Because MongoDB does not know the directory DB.

Fixed Work for me.

Step 1: New Folder eg Run cmd

mkdir  E:\workspace\mongodb\data

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

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

Ok.

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  

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM