Tech Junkie Blog - Real World Tutorials, Happy Coding!: AngularJS SPA : Install MongoDB as a Windows Service

Thursday, March 16, 2017

AngularJS SPA : Install MongoDB as a Windows Service

In the previous blog post we created a configuration file for our MongoDB database in this post we will install MongoDB as a Windows service so that we don't have to start the service in the command line every time we want to use it to save development time.

Here are the steps to install MongoDB:

1.  Open the command prompt as an "Administrator"

2.  Change the mongo-db-config.conf file to use absolute paths.  You can get the instructions on how to create a MongoDB configuration file in this blog post

            dbpath = C:\techjunkie\mongodb\db
            logpath = C:\techjunkie\mongodb\mongo-db-server.log
            verbose = vvvvv

if the folder dpath folder does not exists in Windows create the folder "db" inside the "mongodb" folder, else the service start will fail



3. Type the following command

mongod -f c:\techjunkie\mongodb\mongo-db-config.conf -install




If you have a log file it will be moved to another log file with time stamped.

4.  The MongoDB service is now part of the Windows services





5.  Double-click on the "MongoDB" and click on the "Start" button

6.  If you receive the error "Windows could not start MongoDB service on Local Computer", then it means the previous shutdown of MongoDB was done improperly.
























To resolve this issue do the following:


  1. Remove the file c:/techjunkie/mongodb/db/mongod.lock
  2. Repair mongodb with command mongod --repair
  3. Start the mongoDB service
Note: You can also start and stop the mongoDB service in the command line with the following commands

To Start Type:  net start MongoDB
To Stop Type: net stop MongoDB














1 comment:

Search This Blog