Ubuntu 18.04配置MongoDB密码登录
系统: Ubuntu 18.04 MongoDB: 4.23 安装MongoDB server 和client(测试用) # 添加MongoDB GPG密钥 apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B7C549A058F8B6B # 创建MongoDB存储库 echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list apt-get update apt-get install mongodb-org apt-get install mongodb-clients 启动MongoDB systemctl start mongod.service 登录MongoDB并设置密码 # 登录 mongo # 切换到admin数据库 use admin # 创建admin账号,密码::admin111 权限:root权限,授权的数据库名:admin db.createUser({user:"admin", pwd:"admin111", roles:[{role:"root", db: