mongo create user all rights code example
Example 1: mongodb add user
use <your database>
db.createUser({
user: '<some username>',
pwd: passwordPrompt(),
roles: [{
role: 'readWrite',
db: '<your database>'
}]
})
Example 2: create admin user in mongodb
use admin
db.createUser(
{
user: "username",
pwd: "password",
roles: [ "root" ]
}
)
Example 3: mongodb add admin user
use admin
db.createUser({
user: "username",
pwd: "password",
roles: [ "root" ]
})