mongodb create user with total admin code example
Example 1: mongodb add user
use
db.createUser({
user: '',
pwd: passwordPrompt(),
roles: [{
role: 'readWrite',
db: ''
}]
})
Example 2: mongodb create admin user for all databases
use admin
db.createUser({ user: "mongoadmin" , pwd: "mongoadmin", roles: ["userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase"]})