Tuesday 4 February 2014

MongoDB Installation for MS-Windows


This page explains the installation procedure of MongoDB for MS-Windows environment.

MongoDB Installation
This will setup MongoDB as a service on windows, so that the database will start automatically following each reboot cycle.


  1. Go to http://www.mongodb.org/downloads and choose the appropriate package (Windows 32-bit versus 64-bit; choose *2008+ if you are on Windows-7 64-bit)
  2. Extract the zip-file, and rename the folder to "mongodb"
  3. Move the resulting folder to C:\work resulting in C:\work\mongodb (all files should be in the bin-directory inside mongodb-dir)
  4. Create a directory for storing the generated logs at C:\work\mongodb\log
  5. MongoDB needs a data directory for storage; create a directory C:\work\data\db
  6. Create a config-file at C:\work\mongodb\mongod.cfg directory with the following content
    logpath=C:\work\mongodb\log\mongo.log
    dbpath=C:\work\data
  7. Start the Command Prompt by selecting the Start Menu, then All Programs, then Accessories, then right click Command Prompt, and select Run as Administrator from the popup menu.
  8. In the command-prompt with admin-privileges, type the following commands:
    C:\work\mongodb\bin\mongod.exe --config C:\work\mongodb\mongod.cfg --install
    net start MongoDB
    Description: https://teambox.com/send/cf1fb338f759313f

  9. Exit the cmd-prompt shell. This should install MongoDB as service which will  start automatically following each reboot cycle
  10. Open an ordinary cmd-prompt shell by typing "cmd.exe" in Windows start, and type "C:\work\mongodb\bin\mongo.exe" ; you should see a MongoDB-Shell which is connected to the "test" database.
  11. Type "db.test.save( { a: 1 } )" to add a record to the data-base
  12. Now check if the record was added by typing "db.test.find()"
    Description: https://teambox.com/send/d196efe7d45efd54