MongoDB as a Windows service startup
- Windows version Installation
- MongoDB Official Download Station is http://www.mongodb.org/downloads, can go up to download the latest corresponding version, there are 32-bit, 64-bit.
- Set the Mogodb directory.
Unzip the downloaded compressed package to the specified directory. After I unzip, copy the content to, D:\MongoDB
- Set the data file path
Create a new Data folder under D:\MongoDB and a DB folder under the Data folder
- Set the MongoDB log storage path
Create the logs folder below D:\MongoDB and create the MongoDB.log file
- Configuring the MongoDB Server
- Open the cmd window and go to the Mongodb\bin directory and enter the command:
- Do not set port number, default is 27017 port number
Mongod.exe--logpath D:\MongoDB\logs\MongoDB.log--logappend--dbpath D:\MongoDB\data--directoryperdb--service '
- Set a custom port number
Mongod.exe--port 20161--logpath D:\MongoDB\logs\MongoDB.log--logappend--dbpath D:\MongoDB\data--directoryperdb-- Service
- After the service is created, the default is stop state, we need to manually open the service, with the command, net start MongoDB, open the service.
After the service is turned on, the data folder that was created automatically generates several files, which should be related to the file.
- Client Connection Validation
- After the service is turned on, there are two ways to verify that the success is actually turned on
- Using the command line, MONGO 127.0.0.1:27017 to show that the connection was successful. Connecting To:127.0.0.1:27017/test
- Another way is to enter in the browser: http://localhost:27017/, the page displays such a line of words:
It looks like you is trying to access MongoDB over HTTP on the native driver port.
This can also detect whether the server can be connected, but the ego feels a little bit.
- At this point, our MONGO service is created and can be used normally. Each time you use, enter the name, net start MongoDB to open the service.
- View Logs
- The MongoDB.log under the D:\MongoDB\logs
- Records of operations related to Mogodb are recorded here.
- Add
- The service is created, can be started, stopped, deleted, and the corresponding command line is:
net start MongoDB start-up service
net stop MongoDB stop service
SC Delete MongoDB Delete Service (this command is suitable for most services, only need to change the service name later)
MongoDB as a Windows service startup