im in mongo shell traying to create the 1st superuser with all permissions;
use admin
switched to db admin
MongoDB Enterprise atlas-feuibs-shard-0:PRIMARY> db.createUser({user:'root', pwd:'1234', roles: ['root']})
uncaught exception: Error: couldn't add user: (Unauthorized) not authorized on admin to execute command { createUser: "root", pwd: "1234", roles: [root], digestPassword: true, writeConcern: { w: "majority", wtimeout: 600000.0 }, lsid: { id: {4 [171 148 62 18 97 202 76 208 154 77 242 106 20 185 219 71]} }, $clusterTime: { clusterTime: {1617362319 8}, signature: { hash: {0 [4 101 176 140 52 204 125 92 233 30 123 196 177 26 148 123 7 241 173 182]}, keyId: 6942616266624466944.000000 } }, $db: "admin" } :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1386:11
@(shell):1:1
I can’t access config file:
mongod -f /etc/mongod.conf
uncaught exception: ReferenceError: mongod is not defined :
@(shell):1:1
MongoDB Enterprise atlas-feuibs-shard-0:PRIMARY> db.getUser('m001-student')
{
"_id" : "admin.m001-student",
"user" : "m001-student",
"db" : "admin",
"roles" : [
{
"role" : "readWriteAnyDatabase",
"db" : "admin"
}
]
}
MongoDB Enterprise atlas-feuibs-shard-0:PRIMARY> db.auth('m103-student')
Enter password:
Error: Authentication failed.
0
Created another db called ‘rutas’ but no go:
use rutas
switched to db rutas
MongoDB Enterprise atlas-feuibs-shard-0:PRIMARY> db.createUser({user: 'dios', pwd: 'divine', roles: ['root']})
uncaught exception: Error: couldn't add user: CMD_NOT_ALLOWED: createUser :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1386:11
@(shell):1:1
any ideas how to solve this?
thanks !!!