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')

 

posted @ 2022-01-04 17:43  代码堆里的看客  阅读(26)  评论(0编辑  收藏  举报