Before we start building an MVC4 application with MongoDB as backend, lets install MongoDB. The help file does a pretty good job of outlining details on installation. I choose to install it as a service. I am yet to find a way to have data files as part of my application, something RavenDB does a good job.
The tasks involved in installing and running MongoDB is pretty straightforward.
- Download MongoDB (2.4.1) here. I am using Windows 8 (64-bit).
- Unzip in a folder (C:\tools\MongoDB). I don’t like to put everything in the root folder. It clutters my folder view in windows explorer (too many folders at root level).
- Create two folders in the root (MongoDB folder) namely log and data.
- Start command line as an administrator (first time I didn’t do and it didn’t let me install Mongo as a service. I realize permission issue).
- Issue the command as shown in the picture below.
As you would notice, we have started the service successfully. One important step to remember is that I have given my own path for log and data otherwise Mongo will take default for data and may not start in absence of log folder.
Also, remember to edit config file (mongod.cfg) and include path for data. Here is how config file (edited with Notepad) looks like. The first line was already present (because of –config option given in the command)
logpath=c:\tools\mongodb\log\mongo.log
dbpath=c:\tools\mongodb\data ===>>> Added/edited by me before starting MongoDb as a service.
In the next blog, I will start working on a MVC4 project.
Keep Learning!!!