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.