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

  1. Download and install MongoDB. You can download the 32 or 64-bit version from here.
  2. Make sure you install MongoDB in a folder that you can easily remember, for example: c:mongodb
  3. Add directories c:mongodblog and c:mongodbdata
  4. Add log file c:mongodblogmongo.log

Creating a Windows service for MongoDB

  1. Open your command window and type the following:
    cd c:mongodbbinmongod.exe --install --rest -master -logpath=c:mongodblogmongo.log
  2. Open the registry settings, press the Windows key and R at the same time and then type regedit in the Run command window.
  3. Go to HKEY_LOCAL_MACHINE >> SYSTEM >> CurrentControlSet >> services
  4. Find out MongoDB directory & edit ImagePath key
  5. Set key value as:
    C:mongodbbinmongod --service  --rest  --master  --logpath=C:mongodblogsmongo.log  --dbpath=C:mongodbdata
  6. Save and exit registry editor.
  7. 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.
  8. Find the MongoDB service and right-click on it, select Properties
  9. Make sure the service is set to start automatically and start the service as shown below.mongodb windows service
  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.

Comments

  1. Matt Avatar
    Matt

    Thank you for this tutorial! It got my mongodb service up and running! One thing, I’m not sure if it’s my web browser or the content, but I’m not seeing any forward slashes in the directory paths, and it took me a sec to figure it out.

    1. ricardodsanchez Avatar
      ricardodsanchez

      Thank you for the heads up Matt! I’ve updated the post with the forward slashes in the paths.

  2. Dear sir i copy your line cd c:mongodbbinmongod.exe –install –rest -master -logpath=c:mongodblogmongo.log
    for mongo installation on my window 8 but he is not install

    my cmd starting command show

    c:>

  3. For Install MongoDB on Ubuntu :The Ubuntu package management tool (i.e.dpkg and apt) ensure package consistency and authenticity by requiring that distributors sign packages with GPG keys. Issue the following command to import the MongoDB public GPG Key

Leave a Reply

Your email address will not be published. Required fields are marked *