Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set MongoDB as a windows service

Tags:

mongodb

i am new user of mongodb.I have done the following steps for Installing MongoDB on Windows , Download MongoDB for Windows, Run MongoDB, Start MongoDB, Connect to MongoDB and finally i start mongodb as window service at that time an error is found, when i enter the command "net start mongodb" in command prompt ,the following error is found,: The service is not responding to the control function. How to solve this problem?

like image 749
user3256070 Avatar asked Feb 19 '14 09:02

user3256070


People also ask

Should I install MongoDB as a service?

What difference does setting MongoDB as a service make? Running MongoDB as a service gives you some flexibility with how you can run and deploy MongoDB. For example, you can have MongoDB run at startup and restart on failures. If you don't set MongoDB up as a service, you will have to run the MongoDB server every time.

Why MongoDB is not showing in services?

Run the "Services. msc" command and check if the MongoDB service is installed or not. As we didn't install that service during the installation, you will not be able to find it in the Services window. Now, open the command prompt with admin rights as we are going to install or configure a Windows Service for MongoDB.

How do I start MongoDB services?

You can start MongoDB from a command line by issuing the mongod command and specifying options. For a list of options, see the mongod reference. MongoDB can also run as a Windows service. For details, see Start MongoDB Community Edition as a Windows Service.


2 Answers

The following works fine for me

mongod --install --serviceName "Mongo DB instance" --serviceDisplayName "Mongo DB instance" --port 27017 --dbpath C:\data --logpath C:\data\1.log --smallfiles

Of course you should change the parameters to fit your needs. Make sure that the appropriate folders exist. After installing the service you start it as follows

net start "Mongo DB instance"
like image 91
Horizon_Net Avatar answered Sep 28 '22 06:09

Horizon_Net


1) Download the 64 bit version of mongodb

2) Double click the downloaded file to run the installer

3) Look for MongoDB in C drive If you can't find it there, then look in C:\"Program Files" folder Cut and paste the "MongoDB 2.6 Standard" folder from C:\Program Files to C:\ Rename "MongoDB 2.6 Standard" to MongoDB

4) Create C:\data folder

5) Now open command shell to run as Administrator

6) In the command shell you just opened:

A) Browse to C:\MongoDB\bin folder

B) Then run this command: (Change name and folder accordingly) mongod --install --serviceName "Mongo DB2.6 instance" --serviceDisplayName "Mongo DB2.6 instance" --port 27017 --dbpath C:\data --logpath C:\data\1.log --smallfiles

C) To start the service, you can either run this command: net start "Mongo DB2.6 instance" OR type services in the Search for programs and files box. Then look for Mongo DB2.6 instance > right click it and choose Start

D) Verify that you can connect and run command Open a command prompt

       >cd C:\MongoDB\bin (enter)
       >mongo.exe (enter)
       >it will show that it is connected
       >type command "show dbs" and hit enter
       >it will show local and test dbs
like image 40
kheya Avatar answered Sep 28 '22 05:09

kheya