First, installation
1. Download the installation file for MongoDB under Windows
First go to the official website https://www.mongodb.com/download-center?jmp=nav#community download the installation files. I downloaded it.
2. I am the default installation in the C:\Program files\ directory
3. Create a new C:\mongodb\data, C:\mongodb\logs, and Mongo.config file under the C drive as follows:
4. Create the Mongo.log file in the Logs folder
5. Make the following edits in the Mongo.config file:
Dbpath=c:\mongodb\data #数据库路径
Logpath=c:\mongodb\logs\mongo.log #日志输出文件路径
6. Open the cmd command line, switch to the MongoDB bin directory, execute the command: Mongod--dbpath C:\mongo\data
MongoDB run successfully, browser through: http://localhost:27017/Access results are as follows:
7. Execute in the bin directory: Mongod--config C:\mongodb\mongo.config, view the log file:
Description successfully configured
8. Install as a Windows service, execute:
SC create MongoDB binpath= "C:\Program files\mongodb\server\3.4\bin\mongod.exe--service--config=c:\mongodb\ Mongo.config "( note that there are spaces between" binpath= "and value values )
9. Start: Net start MongoDB (when installing forget to forget to cut this figure, here to borrow other people's figure, my own is 3.4, the figure is 3.2)
Second, the problems encountered
The 1.MONGODB installation package is installed by default to C:\Program Files. When we follow most of the Web tutorials, create the DB folder in the C:\Program files\mongodb\server\3.4 directory, run the command line: Mongod--dbpath C:\Program Files\mongodb\server \3.4\DB, reported invalid COMMAND:FILES\MONGODB\SERVER\3.4\DB error.
Analysis: Path issues
Workaround: Do not create a DB folder under the C:\Program files directory and its subdirectories. For example, my directory is: C:\mongodb\data, so there is no error
2. At the outset, I followed other tutorials by adding the following settings to the Mongo.config file:
Dbpath=c:\mongodb\data #数据库路径
Logpath=c:\mongodb\logs\mongo.log #日志输出文件路径logappend =true #错误日志采用追加模式, after configuring this option, the MongoDB log is appended to the existing log file instead of creating a new file
Logappend=true #错误日志采用追加模式, after configuring this option, the MongoDB log is appended to the existing log file instead of creating a new file
Journal=true #启用日志文件, enabled by default
Quiet=true #这个选项可以过滤掉一些无用的日志信息, set to False if you need to use Debug
port=27017 #端口号 defaults to 27017
The following error occurred:
Then i delete the config file in the next four lines, only the two path settings, there is no such error, do not know the reason (embarrassing)
3. Registration Service Execution: SC create MongoDB binpath= "C:\Program files\mongodb\server\3.4\bin\mongod.exe--service--config=c:\ Mongodb\mongo.config ",[SC] OpenSCManager failure 5:
Analysis: Insufficient user rights,
What needs to be done is regedit open the registry
Change the value of Hkey_local_machine\software\microsoft\windows\currentversion\policies\system\enablelua to 0
Change this value to 0 so that it is the real administration to operate on your own computer.
Restart the computer, open cmd, re-execute SC create MongoDB binpath= "C:\Program files\mongodb\server\3.4\bin\mongod.exe--service--config =c:\mongodb\mongo.config "
Installation of Win10 MongoDB