How to Start mongodb

Source: Internet
Author: User
Tags mongodb

The simplest start method is foreground startup. Only the data directory is specified and the default port 27107 is used. It can be directly used under cli. /mongo is connected to the local mongodb, which is generally only used for temporary development and testing.

The code is as follows: Copy code

./Mongod -- dbpath =/path/mongodb

2. Start binding a fixed IP address and port, so mongo needs to specify the IP address and port when connecting to mongod.

The code is as follows: Copy code

./Mongod -- dbpath =/path/mongodb -- bind_ip = 10.10.10.10 -- port = 12345

// Connect to mongod

./Mongo 10.10.10.10: 12345

3. Run daemon in the background. Simply add "&" to the command "&".

The code is as follows: Copy code
./Mongod -- dbpath =/path/mongodb -- bind_ip = 10.10.10.10 -- port = 12345 &

You can also use the -- fork parameter that comes with mongod to specify the log path.

The code is as follows: Copy code

./Mongod -- dbpath =/path/mongodb -- fork = true logpath =/path/mongod. log

4. (recommended) save the configuration as a configuration file.

The code is as follows: Copy code

Port = 12345

Bind_ip = 10.10.10.10

Logpath =/path/mongod. log

Pidfilepath =/path/mongod. pid

Logappend = true

Fork = true

Then introduce the configuration file when mongod is started.

The code is as follows: Copy code

./Mongod-f/path/mongod. conf

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.