Installation and remote connection of MONGODB under CentOS

Source: Internet
Author: User
Tags mongodb centos
First, installation ① Add the MONGO installation configuration to Yum

Vi/etc/yum.repos.d/mongodb-org-3.4.repo

Copy the following configuration to a file

[mongodb-org-3.4]
Name=mongodb Repository
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.4/x86_64/
Gpgcheck=1
enabled=1
GPGKEY=HTTPS://WWW.MONGODB.ORG/STATIC/PGP/SERVER-3.4.ASC
② running the install command

sudo yum install-y mongodb-org

The following log appears to indicate that the installation was successful.

③ Setting the data storage path

By default, the MONGO storage path is/data/db, and if this file is not present in the system, it will not start successfully. So to manually wear this folder

Mkdir-p/data/db ④ start MONGO

sudo service Mongod start

The following log appears to indicate the success of the startup.

⑤ connecting the local MONGO

Mongo

At this time the installation of MONGO has been completed, the above log warning what can be resolved through the configuration, but does not affect the use.

Reference: https://docs.mongodb.com/master/mongo/ Two, MONGO remote connection

Note: MONGO remote connection requires permission control to be turned on
This tutorial is not too much about permissions issues, permission details can be consulted:
http://www.cnblogs.com/hanyinglong/archive/2016/07/25/5704320.html ① Adding a new user

First add an administrator account (root):

Db.createuser ({
    User: "Root",
    pwd: "Password",
    roles:[{role: "Root", DB: "Admin"}]
    })

Add a regular account (read and write access):
(The DB in the command represents the database assigned by the user)

Db.createuser ({
                User: "Zhanghao",                                   
                pwd: "Mima",
                roles:[{role: "ReadWrite", DB: "Test"}]
           });
② Modifying a configuration file

Vi/etc/mongod.conf

Commented out:
bindip:127.0.0.1  # Listen to local interface only, comment to Listen on all interfaces.

Added:
Security:
    authorization:enabled
③ Restart MONGO remote connection

Service Mongod Restart

Open Robo (MONGO Visualizer):

Finally click on save to be happy to use.

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.