It is inconvenient to run mongod -- dbpath D:/MongoDB/Data command line to start MongoDB every time. Just like MySQL without installation, I want to use it as a Windows service, this makes it much easier.
D: \ MongoDB \ bin> mongod -- logpath D: \ MongoDB \ logs \ MongoDB. log -- logappend -- dbpath D: \ MongoDB \ data -- directoryperdb -- servicename MongoDB -- install
All output going to: D: \ MongoDB \ logs \ MongoDB. Log
Creating service MongoDB.
Service creation successful.
Service can be started from the command line via 'net start "MongoDB "'.
Note: This command will be run in the bin directory of MongoDB. At the beginning, I will run it directly under D: \. The Executable Directory of the result service is ["D: \ mongod "-- logpath" D: \ MongoDB \ logs \ MongoDB. log "-- logappend -- dbpath" D: \ MongoDB \ data "-- directoryperdb -- Service] is definitely incorrect.
The command line specifies the log file D: \ MongoDB \ logs \ MongoDB. log, which is output in append mode;
Data File directory: D: \ MongoDB \ data. The parameter -- directoryperdb indicates that a new directory is created for each database;
Windows Service name: MongoDB;
The above three parameters can be set based on your own situation.
The last installation parameter is -- install, which is opposite to -- remove.
Start MongoDB: Net start MongoDB
Stop MongoDB: net stop MongoDB