rpm --import https://www.mongodb.org/static/pgp/server-5.0.asc
vi /etc/yum.repos.d/mongodb-org-5.0.repo
[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc

yum install -y mongodb-org

登录数据库创建用户
mongo
use admin
db.createUser({ user: "帐号", pwd: "密码", roles: ["root"] })
启用身份验证
sudo vi /etc/mongod.conf
security:
  authorization: enabled
开启远程访问
bindIp: 0.0.0.0


systemctl start mongod
systemctl enable mongod
systemctl status mongod