Installing MongoDB as a service

In MongoDB 2.6, the steps provided in this site on how to install MongoDB as a service is not working correctly. They confirmed that this is a bug and that a fix will come up soon. In the meantime, here is a work around for this issue.

  1. Install MongoDB.
    My directory is at “C:\Program Files\MongoDB 2.6 Standard”
  2. Create this folder: “C:\Program Files\MongoDB 2.6 Standard\data\db”
  3. Create this folder and file: “C:\Program Files\MongoDB 2.6 Standard\logs\mongo.log”
  4. Create this file: “C:\Program Files\MongoDB 2.6 Standard\mongod.cfg”
  5. Inside mongod.cfg, insert these values:
    logpath="C:\Program Files\MongoDB 2.6 Standard\logs\mongo.log"
    dbpath="C:\Program Files\MongoDB 2.6 Standard\data\db"
  6. Run this command in the command prompt:
    sc create MongoDB binPath= "\"C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB 2.6 Standard\mongod.cfg\""DisplayName= "MongoDB 2.6 Standard" start= "auto"
  7. Run regedit.exe and navigate to HKEY_LOCAL_MACHINE >> SYSTEM >> CurrentControlSet >> services >> MongoDB
  8. Modify ImagePath by inserting these new values:
    "C:\Program Files\MongoDB 2.6 Standard\bin\mongod" --service --rest --master --logpath="C:\Program Files\MongoDB 2.6 Standard\logs\mongo.log" --dbpath="C:\Program Files\MongoDB 2.6 Standard\data\db"
  9. Try to check http://localhost:28017/ if it’s accessible.