MongoDB的安装
1、vi /etc/yum.repos.d/mongodb-org.repo [mongodb-org-4.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc 2、yum update 3、yum install mongodb-org -y 4、查看并启动mongodb,并将服务设置为开机自启动 systemctl status mongod systemctl start mongod systemctl enable mongod -------- db.createUser( { user: "root", pwd: "pwd", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } ) mongo -u "root" -p db.system.users.find(); db.changeUserPassword('root','pwd1') use admin db.auth('root','pwd1')