Install MongoDB service on Windows 8
MongoDB (from “humongous”) is an open-source document database, and the leading NoSQL database. Written in C++.
MongoDB is great for modeling many of the entities that back most modern web-apps, either consumer or enterprise:
- Account and user profiles: can store arrays of addresses with ease
- CMS: the flexible schema of MongoDB is great for heterogeneous collections of content types
- Form data: MongoDB makes it easy to evolve structure of form data over time
- Blogs / user-generated content: can keep data with complex relationships together in one object
- Messaging: vary message meta-data easily per message or message type without needing to maintain separate collections or schemas
- System configuration: just a nice object graph of configuration values, which is very natural in MongoDB
- Log data of any kind: structured log data is the future
- Graphs: just objects and pointers – a perfect fit
- Location based data: MongoDB understands geo-spatial coordinates and natively supports geo-spatial indexing
However, if you are installing it on Windows 8, there is a little problem. In the MongoDB website they offer instructions on how to create a Windows service for MongoDB manually but unfortunately it doesn’t work. If you follow the instructions mentioned in their website, you’ll soon find out that the service won’t start and you’ll be very frustrated.
Here are the steps that you really need to follow to create a Windows service for MongoDB in Windows 8:
Installing MongoDB on Windows 8
- Download and install MongoDB. You can download the 32 or 64-bit version from here.
- Make sure you install MongoDB in a folder that you can easily remember, for example: c:mongodb
- Add directories c:mongodblog and c:mongodbdata
- Add log file c:mongodblogmongo.log
Creating a Windows service for MongoDB
- Open your command window and type the following:
cd c:mongodbbinmongod.exe --install --rest -master -logpath=c:mongodblogmongo.log
- Open the registry settings, press the Windows key and R at the same time and then type regedit in the Run command window.
- Go to HKEY_LOCAL_MACHINE >> SYSTEM >> CurrentControlSet >> services
- Find out MongoDB directory & edit ImagePath key
- Set key value as:
C:mongodbbinmongod --service --rest --master --logpath=C:mongodblogsmongo.log --dbpath=C:mongodbdata
- Save and exit registry editor.
- Open Services by pressing the Windows key and R at the same time and then type services.msc in the Run command window and click OK.
- Find the MongoDB service and right-click on it, select Properties
- Make sure the service is set to start automatically and start the service as shown below.
- Open your browser and go to http://localhost:28017/ to see if MongoDB is running correctly, you should see a page full of MongoDB details.