This article describes installing MongoDB in a Windows environment and adding it to a Windows service, starting with the system
First go to the official website to download the Windows installation package: Https://www.mongodb.org/downloads
In general, choose the default 64-bit (unless your host is 32-bit), after downloading, suppose we install to: d:/soft/mongodb/, after completion, enter the directory, create a new data and logs two folders, and in the logs directory to create a new mongodb.log. Then open a command prompt (CMD) and the Windows8.1 user needs to be opened as an administrator. Execute the following command:
D: && cd/soft/mongodb/bin--dbpath d:/soft/mongodb/data
This way MongoDB starts happily, opens the browser, enters: http://127.0.0.1:27017, then you will see the following prompt language:
You is trying to access MongoDB on the native driver port. For HTTP diagnostic access, add the port number
In fact it is painful to start MONGO every time through the command line, so we need to create a permanent service, which requires us to add MONGO to the Windows Local Service. Continue back to CMD, execute:
Since we have entered the D:/soft/mongodb/bin directory before, we just need to execute the following command: Mongod.exe--logpath d:/soft/mongodb/logs/mongodb.log--logappend-- DBPath d:/soft/mongodb/data--directoryperdb--servicename mongodb-install --auth
net start MongoDB
The red character--auth This parameter means that the service will turn on permission authentication, plus this parameter will not be free to open the MongoDB database on your server.
Open the Services window and you will see the results we need:
By the way, how to remove the Windows service: first stop the current MongoDB service in the service settings. Then run at the command line (the current path can be anywhere):SC Delete MongoDBThis will cause the previously installed services to be deleted.
MongoDB install and add to Windows Service, boot with system