mongodb添加用户

来源:互联网 发布:淘宝优质家具卖家 编辑:程序博客网 时间:2024/04/25 13:15

db.createUser({user:"user",pwd:"user",roles:["dbOwner"]})


  • 如果 MongoDB 开启了权限模式,并且某一个数据库没有任何用户时,在不验证权限的情况下,可以创建一个用户,当继续创建第二个用户时,会返回错误,若想继续创建用户则必须登录。

    2014-10-16T10:40:41.904+0800 Error: couldn't add user: not authorized on mydb to execute command { createUser: "test", pwd: "xxx", roles: [ { role: "dbOwner", db: "mydb" } ], digestPassword: false, writeConcern: { w: "majority", wtimeout: 30000.0 } } at src/mongo/shell/db.js:1004>
  • 创建超级管理员


原创粉丝点击