MongoDB add to Windows Services and set environment variables

Source: Internet
Author: User
Tags mongodb mongodb add

has been using the Ubuntu system for some time, because the use of the source installed MongoDB, so everything is configured by default, open the Shell Direct Input MONGO command can be used. Yesterday to the notebook installed a win10, ready to turn the development environment to Windows (because of the beautiful editor on Ubuntu, such as sublime but not smart code hints, using the Webstorm interface font effect on the egg pain, the habit of VS). This article will be recorded in my win under the configuration of the MongoDB process.

The premise of this article is to download and install the MongoDB from the official website, and my installation directory is d:\xiaoboy.com\mongodb\

Add MongoDB to the Windows service

Before adding a service, add two directories under D:\xiaoboy.com\mongodb\: Log and data, and create a new file Logs.log in the log directory. After completing the steps above, start cmd as an administrator, enter the d:\xiaoboy.com\mongodb\bin\ directory at the command line, and then enter the following command:


Mongod.exe--logpath "D:\xiaoboy.com\mongodb\log\logs.log"--logappend--dbpath "D:\xiaoboy.com\mongodb\data"-- Directoryperdb--servicename MongoDB--install

Some people say that after running the above command will be successful after the prompt, but I do not have a hint, open the Windows service will be able to see the service I have just created, the fact that I have been installed successfully (if not started the service remember to start manually).

Add MongoDB to an environment variable

There are two ways to open and manipulate MongoDB:

Manually run the D:\xiaoboy.com\mongodb\bin\mongo.exe file, you can open a command line window;
Create a new CMD window, CD to the D:\xiaoboy.com\mongodb\bin\ folder, and then enter the MONGO command;
In Ubuntu, I can directly open the Shell Input MONGO command to operate MongoDB, but open cmd in Windows prompts a command error. Is there a way to operate MongoDB in Windows like Ubuntu? The idea is to set an environment variable to use the node command in the global when you install Nodejs earlier, so I use the same method to set the MongoDB, which is feasible, and the steps set are as follows (shrimp and Tiger fish original):

Access to advanced system settings;

Enter into the environment variable;

Find the variable name in the system variable named path double-click enter;
Join at the end of the variable value; d:\xiaoboy.com\mongodb\bin\ (don't omit the semicolon), save;
Then create a new cmd, input MONGO try.
In fact, the *.exe files in the d:\xiaoboy.com\mongodb\bin\ directory can be run directly in CMD, such as database restore Mongorestore and backup mongodump commands, etc.

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.