As a result of the recent learning Nodejs, when used to the database, the feeling MongoDB and Nodejs very well, all installation MongoDB try, by the way, more than the pressure on the body. about how to install MongoDB, I saw a lot of blog on the Internet have introduced, I have skipped here. OK, get to the point.
To add a MongoDB service to the system:
1, in the installation directory (my installation directory is D:\MongoDB) under a new DB folder as a database storage path, create a new log folder to store logs.
2, Win+x+a Open the Administrator command prompt, and use the following command to create a profile mongod.cfg.
echo Logpath=d:\mongodb\log\mongod.log>d:\mongodb\mongod.cfg
Echo dbpath=d:\mongodb\db>>d:\mongodb\ Mongod.cfg
One thing to note here is that if your path contains spaces, you can "" surround them, for example: Echo logpath= "D:\Program Files\mongodb\log\mongod.log" >d:\mongodb\ Mongod.cfg.
3, the use of SC command to create MongoDB services, the following command:
Sc.exe Create MongoDB binpath= "D:\MongoDB\bin\mongod.exe--service--config=d:\mongodb\mongod.cfg"
The illustration shows the MongoDB service creation success.
4, start the service
net start MongoDB
Appears as shown in the figure, indicating that the MongoDB service started successfully. You can win+r, enter services.msc to open a list of Windows services, and you can see MongoDB services.
At this point, you can start and stop the MongoDB service in the list of services.
5. Shutdown Service and Delete service
To turn off service usage commands:
net stop MongoDB
To delete a service usage command:
Sc.exe Delete MongoDB
Of course, you can also operate in the list of services.
The above is about how to add a MongoDB service to the system without having to open a DOS window more.