1 yum安装
1.1 编辑安装源
yum install vim -y
vim /etc/yum.repos.d/mongodb.repo
内容
[mongodb-org]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=0
enabled=1
1.2 yum安装
目前最新版是5.x,生产环境一般会用4.4.x,4的最新版是4.4.13,偶数版用于生产所以安装4.4.12
yum install mongodb-org-4.4.12 -y
1.3 修改配置
vim /etc/mongod.conf
bindIp: 0.0.0.0
1.4 启动服务
systemctl start mongod.service
systemctl stop firewalld.service
systemctl disable firewalld.service
1.5 创建用户客户端测试
mongo
use admin
db.createUser({
user:'root',
pwd:'123456',
roles:[{role:"root",db:'admin'}]
}
);
image.png
image.png
网友评论