1、添加repo
centos7:
vi /etc/yum.repos.d/mongodb.repo
[MongoDB]
name=MongoDB Repository
baseurl=http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
debian:
apt install dirmngr gnupg apt-transport-https software-properties-common ca-certificates curl
curl -fsSL https://www.mongodb.org/static/pgp/server-4.2.asc |apt-key add -
add-apt-repository 'deb https://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main'
apt update -y
2、安装
centos7:
yum install mongodb-org -y
debian:
apt install mongodb-org
3、启动
systemctl start mongod.service
systemctl enable mongod.service #开机启动
4、创建root用户。
执行mongo
use admin;
db.createUser({user: "root", pwd: "password", roles: [{role: "root", db: "admin"}]});
创建普通用户:
use test2db
db.createUser({user: "test2", pwd: "test2", roles: [{role: "readWrite", db: "test2db" }]})
本文由 admin 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Jan 19, 2021 at 10:00 am