Run MongoDB as a Service in Windows

Run MongoDB as a Service in Windows

Image for postMongoDB windows service

Today we will learn How to Setup and run MongoDB windows service continuing our MongoDB Development Tutorials series. MongoDB king of NoSQL databases, check out Introduction to MEAN Stack article to know why. In this article, You will learn to Setup, config, start and run MongoDB As a Service in Windows PC to be precise Windows 10 64bit and 32 bit, Windows 7 64bit and 32 bit.

If you haven?t installed MongoDB on your Windows Pc please Go to the Official website of MongoDB and download the latest setup file 32bit or 64 bit according to your pc architecture.Now let?s start how we can install mongodb windows service.

When you?re installing MongoDB, please select c:/mongodb as directory for easier access and future uses

Before installing mongodb windows service, we will set up MongoDB environment as follows:

MongoDB required Directory to store all database to set that directory Create Data folder inside c:/mongodb or you can specify any folder of your choice and preference or MongoDB will use datadb inside your MongoDB Installation.

Image for post

To start MongoDB, run mongod.exe from the Command Prompt navigate to your MongoDB Bin folder and run mongod command, it will start MongoDB main process and The waiting for connections message in the console.

Image for post

If you want to connect mongodb through shell, use below commands

Image for post

How to Run MongoDB as Windows Service

Start CMD, Command Prompt as Administrator and create following directories, if you haven?t created already.

Image for post

create the config file in mongodb installation folder, which is c:/mongodb in our case.

Image for post

To install mongodb windows service, use the following command in Command Prompt as Administrator

?C:MongoDBbinmongod.exe? ? config ?C:MongoDBmongod.cfg? ? install

To start MongoDB Windows service use the following command

net start MongoDB

To stop MongoDB windows service

net stop MongoDB

if want to remove MongoDB service from windows

?C:MongoDBmongod.exe? ? remove

**If you?re facing any problem, please run Command Prompt as Administrator and you can also comment below if you?ve any queries.

Article first appeared on Stackfame.com

21