Centos7上yum安装mongodb4-2

vim /etc/yum.repos.d/mongodb-org-4.2.repo

[mongodb-org-4.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc

开启外网访问

vim /etc/mongod.conf
Centos7上yum安装mongodb4-2

常用命令

systemctl restart mongod
systemctl status mongod
systemctl enable mongod
systemctl stop mongod

创建用户

use oa
show users
db.createUser({user: "root",pwd: "123456",roles: [ { role: "dbOwner", db: "oa" } ]})

上一篇:mongoDb 的启动方式


下一篇:ansible 部署mongodb集群(三台主机)