mongodb create superuser code example
Example 1: create admin user in mongodb
use admin
db.createUser(
{
user: "username",
pwd: "password",
roles: [ "root" ]
}
)
Example 2: mongodb readwrite to all dbs
use admin
db.createUser({
user: '<some username>',
pwd: passwordPrompt(), // or '<your password>'
roles: [ "userAdminAnyDatabase", "readWriteAnyDatabase" ]
})