Install MongoDB on windows | SansSQL

Tuesday, November 5, 2013

Install MongoDB on windows

Installing MongoDB on windows is very easy and happens in 3 simple steps.
MongoDB is self-contained and does not have any other system dependencies. You can run MongoDB from any folder you choose.

One: Download the MongoDB binaries from its website.

There are 3 builds available for windows
  1. MongoDB for Windows 2008 R2 - This runs on only Windows Server 2008 R2, Windows 7 64-bit, and newer versions of Windows and takes advantage of recent enhancements to the Windows Platform and cannot operate on older versions of Windows.
  2. MongoDB for Windows 64-bit - This runs on 64-bit version of windows operating system
  3. MongoDB for Windows 32-bit - This runs on 32-bit version of windows operating system

Two: Extract the contents of the downloaded file to a secure path on your server

Three: Run mongod.exe and your MongoDB Server is now ready for next steps

By default, when you run the mongod.exe it will look for the data folder at C:\data\db\.
If this folder does not exist then it will fail to start. However you can also start the mongod.exe using the alternate path by specifying the --dbpath parameter
For example, to use the path "E:\MongoDB_Data\" for db then run the following command using the command prompt "E:\MongoDB_Binaries\bin\mongod.exe --dbpath E:\MongoDB_Data"

Install the mongod.exe as windows service

The most convenient way to manage the mongod.exe is to install it as a windows service.
For installing as a service, the parameter --logpath is mandatory.
Also you can use a config file for specifying the values during setup.

Execute the following command using command prompt for creating the MongoDB service
E:\MongoDB_Binaries\bin\mongod.exe --logpath E:\MongoDB_Log\MongoDbLog.txt --dbpath E:\MongoDB_Data --install

Once the commands are executed, the start the service

Using Config file

If you want to use a config file for doing this, then create a .cfg file as show below
Once the file is created, execute the below command using command prompt
E:\MongoDB_Binaries\bin\mongod.exe --config E:\MongoDB_Binaries\bin\Mongod.cfg --install

Once the commands are executed, the start the service

Uninstall MongoDB Service

To uninstall MongoDB service, execute the below commands using command prompt
E:\MongoDB_Binaries\bin\mongod.exe --remove

No comments:

Post a Comment