MongoDB Learning Notes (introductory tutorial) Series 1-Start and close MongoDB

Source: Internet
Author: User
Tags mongo shell

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.