下载网址
https://www.mongodb.com/try/download/community

安装
RPM安装
wget https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.4/x86_64/RPMS/mongodb-org-server-4.4.6-1.el7.x86_64.rpm
rpm -iUvh mongodb-org-server-4.4.6-1.el7.x86_64.rpm
安装客户端
wget https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.4/x86_64/RPMS/mongodb-org-shell-4.4.6-1.el7.x86_64.rpm
rpm -iUvh mongodb-org-shell-4.4.6-1.el7.x86_64.rpm
启动与停止
systemctl start mongod
systemctl enable mongod
systemctl stop mongod
systemctl disable mongod
systemctl status mongod
配置文件(开启鉴权)
#先在无鉴权情况下,创建鉴权用户
mongo #连接mongo
use admin #切换数据库
db.createUser(
{
user: "myUserAdmin",
pwd: "abc123",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
#修改配置,开启鉴权
vim /etc/mongod.conf
#内容:
security:
authorization: enabled
