Linux之MongoDb权限配置

进入shell

mongo

切换DB 

use admin

添加超级管理员

db.createUser({user:'username', pwd:'password', roles:['userAdminAnyDatabase']}); 

配置开启用户权限验证

vim /etc/mongod.conf

修改或者添加配置

bindIp:0.0.0.0
security:
  authorization: enabled

数据库配置用户和权限

use dbName
db.runCommand({ createUser: "username1", pwd: "password1", roles: [ { role: "readWrite", db: "gy_filedb" } ] });

你可能感兴趣的:(运维)