MongoDB the method of installing to Windows Service and the perfect solution to the problems encountered _mongodb

Source: Internet
Author: User
Tags install mongodb mongodb

MongoDB installation method for details please see: MongoDB installation method

Configure the MONGODB environment variables and benefits

Today we'll talk about how to configure MongoDB's environment variables and benefits, because every time we start the MongoDB service we need to switch to the MongoDB location in the Black window (DOS window) and then execute the net start MongoDB command to open the service. So every time the manual boot to open MongoDB service is particularly troublesome, in order to solve this problem. We can configure the MongoDB to the system environment variable. The next time you can turn on the boot to open the Black window or as an administrator to open (DOS window) input net start MongoDB command, do not need to switch to the path where MongoDB to start.

Configure Environment variables

Mouse click on my Computer right key properties

Click Advanced System Settings

Click on Environment variables

Locate system Variable Click New

Variable names are written casually (but remember to use them later)

Variable value write the directory you installed MongoDB to the Bin directory cut-off (write complete as above) Click OK

Locate the path variable in the system variable click Edit

Variable name does not need to be changed

The variable value is preceded by the name of the variable that was created (my previous step was created with the name Mongdb_home)

The format is%mongdb_home%\bin; (note that the last must be used; Separated) after completion as shown in the above figure click OK


Test whether the MONGODB environment variable is configured successfully

Open Doc Command Window (for more information, see the top of MongoDB's installation blog)

Input command Mongod-help (shown in Figure MONGODB environment variable configuration has been successful)

Next we're going to put MongoDB in the Windows service.

Open Doc Command Window (for more information, see the top of MongoDB's installation blog)


Enter the above command mongod.exe--logpath d:/develop/mongodb/data/logs/mongodb.log--logappend--dbpath d:/develop/mongodb/data/ DB--directoryperdb--servicename Mongodb-install

Briefly describe the parameters used and their implications:

--install: Install MongoDB Service

--logappend: Automatically cut log per day

--servicename: Service name to use when installing Windows service

--servicedisplayname: Service name displayed in Windows Service Manager

--logpath:mongodb log output file name. Although this parameter literal translation is "log path", in fact, to specify a specific full file name. Here I am using the MongoDB.Log file in the C-packing directory. This file is not created in advance and is specified directly.

--dbpath: Specifies the path where the MongoDB data is stored. This is the most critical parameter, not only the directory to exist, and it is best not to end with "\".

--DIRECTORYPERDB: This parameter is very good to understand, let MongoDB according to the database, for each database to create a directory, so-called "directory per database"

Click the Start button on the lower left to click the Run button in the image above

Enter Command services.msc

Finding the Mogodb service in the service has been successfully installed


Right button MongoDB Click Start

Successful MongoDB service has been opened

Another way to start a MongoDB

Open Doc Command Window (for more information, see the top of MongoDB's installation blog)

Enter command cmd


Enter command net start MongoDB

Service started successfully

Problems that may be encountered during installation

Start mongobd times wrong: window can no longer start the local computer MongoDB, as follows:

Solving method

Install--dbpath path found during MongoDB installation to Windows

My installation path is--dbpath d:/develop/mongodb/data/db


So all the data in DB is deleted according to the path of the installation


In the start-up MongoDB can run perfectly

The above is a small set to introduce the MongoDB installation to Windows services and the solution to the problem of the perfect solution, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.