Recently learning MongoDB, in order to deepen the memory, write a writing essay, first start and close MongoDB start
1. Start a MongoDB service:
Mongod--port XXXX--dbpath/xx/xx--logpath mongo.log--fork
There are four parameters in this command:
--port xxxx Specifies the port of MongoDB listening, if the XXXX port is already occupied, it will fail to start
--DBPATH/XX/XX MongoDB Database directory, this directory if it has been occupied by other MongoDB process, will also start failure
--logpath Mongo.log specifying log files
--fork running the MongoDB service in the background, using--fork must specify both the log file (--fork and--logpath must be used simultaneously)
PS: The combination of a port and a dbpath can be seen as the ID of a MongoDB service, so port and DBPath for two MongoDB services cannot be duplicated
2. Close one of the MongoDB services:
First Execute:
MONGO Ip:port (IP is the ip,port of MongoDB service is the port that the MongoDB service listens to)
It then enters the MONGO shell.
Then proceed in turn:
Use admin
Db.shutdownserver ()
You can close the MongoDB service as shown in
Well, the simplest way to start and close is that, of course, you can do more than that when you actually start the MongoDB service.
Here are two commands: Mongod and MONGO, the former is MongoDB's management command, can start and configure the database, the latter is a mongodb shell, can be used to modify & query the contents of the database. These two commands are not to be confused.
MongoDB Learning Notes (introductory tutorial) Series 1-Start and close MongoDB