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 here, 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:\mongodb\log and c:\mongodb\data
- Add log file c:\mongodb\log\mongo.log
Creating a Windows service for MongoDB
- Open your command window and type the following:
cd c:\mongodb\bin\mongod.exe --install --rest -master -logpath=c:\mongodb\log\mongo.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:\mongodb\bin\mongod --service --rest --master --logpath=C:\mongodb\logs\mongo.log --dbpath=C:\mongodb\data
- 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.
10. 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.