MongoDb is a pretty nifty NoSql Big Data database which I use mainly in Nodejs development. Writing code for MongoDb is really easy and straightforward. Yet installing it can be a bit of a challenge. It isn't that hard, but it can be a bit unusual for a standard .Net developer.
I know there are lots of resources on this topic out there. But since I seemed to find myself searching for them time and time again, I decided to write a short blogpost about it myself.
After you download the binaries you will immediately notice that you don't have an installer file. You will have to register the assemblies and start the database instance manually.
Luckily you can install MongoDb as a Windows Service, which I'll explain how to do in this post.
Place the downloaded assemblies in the folder you want to use as root for your MongoDb installation. I'll use:
Create a data folder:
md data md data\db
You can now run your MongoDb instance: (if your path includes spaces, enclose the entire path in double quotations)
C:\Apps\MongoDb\mongod.exe --dbpath c:\Apps\MongoDb\data
I want my MongoDb instance to run as a service though.
Make sure your instance is not running before proceeding with the next steps !
Create a log folder for your Windows Service:
Create a 'mongod.cfg' file in your MongoDb installation folder. Save it with the following data:
Install the actual Windows Service using the following command:
C:\Apps\MongoDb\mongod.exe --config C:\Apps\MongoDb\mongod.cfg --install
And eventually use the following command to start your newly created service:
net start MongoDB
MongoDb will now be listening on the default port 27017!
If you for some reason would like to remove the MongoDb service, use the following commands:
net stop MongoDB C:\Apps\MongoDb\mongod.exe --remove