4 MINDS

4MINDS Gestão de Conhecimento

Mongo 2.6 create new user





use admin

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

or

db.createUser({user:"username",pwd:"password", roles:[{role:"root",db:"admin"}]})

use dbname

db.createUser(
    {
      user: "username",
      pwd: "passsowrd",
      roles: ["readWrite"]
    }
)

db.grantRolesToUser(
    "username",
    [
      { role: "readWrite", db: "dbname" }
    ]
)