Skip to content

Instantly share code, notes, and snippets.

@vijayanandrp
Last active November 24, 2017 13:40
Show Gist options
  • Save vijayanandrp/ddf72c2089015ee3f13be2b1a06bfd08 to your computer and use it in GitHub Desktop.
Save vijayanandrp/ddf72c2089015ee3f13be2b1a06bfd08 to your computer and use it in GitHub Desktop.
Windows mongodb setup and run as a service - https://informationcorners.com/pymongo-wrapper

Add the MongoDB path to system environment variables

(RightClick) This PC -> Properties -> Advanced System Settings (Leftside-down) -> Environment Variables -> path (system variables) -> add below values at the end

;C:\Program Files\MongoDB\Server\3.2\bin;

Open C: drive, create a folder named

C:\MongoDB

Inside MongoDB folder create

  C:\MongoDB\data\db 
  C:\MongoDB\log\mongo-server.log 

Create a file named 'c:\MongoDB\mongod.cfg'

  bind_ip = 127.0.0.1
  dbpath = C:\MongoDB\data\db
  logpath = C:\MongoDB\log\mongo-server.log
  verbose = v

Open a new command prompt as administrator & execute below commands,

"C:\Program Files\MongoDB\Server\3.2\bin\mongod.exe" --config "c:\MongoDB\mongod.cfg" –install

To run as service in windows, execute below command in command prompt

net start MongoDB

You can validate MongoDB service by typing mongo in command prompt. A new shell will be opened.

@JohannesStoye
Copy link

Nice setup list.
But please: always enquote spaces in windows paths!
C:\Program Files\MongoDB\Server\3.2\bin -> "C:\Program Files\MongoDB\Server\3.2\bin"
-> "C:\Program Files\MongoDB\Server\3.2\bin\mongod.exe" --config c:\MongoDB\mongod.cfg –install
(because of Microsofts search order)

@vijayanandrp
Copy link
Author

Hi JohannesStoye,

Thanks for pointing. Noted and updated.

Thanks,
Vijay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment