It’s normal to run your database in auto mood that when you start your computer MongoDB should run as service in background without even initiating any command line for that, in windows machine which I will be showing you the steps we can do it by installing MongoDB as service but in linux environment we need to add it in init.d script and start it that way.

So let’s see the steps to install it as service in windows but before that you need to create your configuration file and point it to the install command if you don’t know how to create the configuration file then please take a look at my other article that show you how to do that but in this article I will only focus on adding this as service in windows machine and the command for that is as bellow:

mongod –f c:\mongod.conf –install

The above command will go ahead and add MongoDB as services in windows but you have to make sure to open your command line as administrator as this need administration right, if your configuration was okay then you will see a success message as bellow screenshot.

Running mongo as Services Screenshot for Mongo Services

If in any case you configured your MongoDB configuration then you get error you can simply google that error message or you can contact me with error message you got I would be glad to help you, after you install it successful we need to start the MongoDB with bellow command.

Net start mongodb

To check if Mongodb is running in your machine you can simply issue bellow command:

Net start | findstr Mongo

Which will filter out all service running in current machine with MongoDB on it if you issue only (net start) it will show all service but with findstr will filter only service with Mongo.

And to stop MongoDB from the windows machine you can simply do that by running bellow command:

Net stop Mongodb

And sure enough you will see that Mongo is stopped and not running anymore to verify that you need to run the first command where you filter the services that starts with MongoDB to illustrate that I have got the actual screenshot where I typed the commands you can see yourself.

Running mongo as Services Screenshot for MongoDB Status

Hope this help you out if it did or if you have any suggestion please let me know your comments and what you want to learn and subscribe to my blog to get latest blog entry in your mail, thanks for reading.