y
Size: a a a
y
DS
not authorized> db.runCommand({connectionStatus : 1})
{
"authInfo" : {
"authenticatedUsers" : [
{
"user" : "root",
"db" : "admin"
}
],
"authenticatedUserRoles" : [
{
"role" : "root",
"db" : "admin"
}
]
},
"ok" : 1
}y
> db.runCommand({connectionStatus : 1})
{
"authInfo" : {
"authenticatedUsers" : [
{
"user" : "root",
"db" : "admin"
}
],
"authenticatedUserRoles" : [
{
"role" : "root",
"db" : "admin"
}
]
},
"ok" : 1
}y
dbAdminAnyDatabase includes local and config databases. To provide dbAdmin privileges on the local database, create a user in the admin database with dbAdmin role in the local database.y
"role" : "root",
"db" : "admin <-----y
y
DS
"role" : "root",
"db" : "admin <-----> use local
switched to db local
> db.createUser({ user: "root", pwd: "pass", roles: [{role: "root", db: "local"}]})
2020-04-29T14:44:52.839+0200 E QUERY [thread1] Error: couldn't add user: Cannot create users in the local database :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1437:15
@(shell):1:1
db.createUser({ user: "root", pwd: "pass", roles: [{role: "dbAdminAnyDatabase", db: "local"}]})
2020-04-29T14:45:32.230+0200 E QUERY [thread1] Error: couldn't add user: Cannot create users in the local database :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1437:15
@(shell):1:1
Тоже самое и для назначения ролиched to db adminм просто нет таких ролей. И создать их нельзя
> db.grantRolesToUser('root',[{role:"root",db:"local"}])
2020-04-29T14:48:21.148+0200 E QUERY [thread1] Error: No role named root@local :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.grantRolesToUser@src/mongo/shell/db.js:1640:19
@(shell):1:1
Та
y
> use local
switched to db local
> db.createUser({ user: "root", pwd: "pass", roles: [{role: "root", db: "local"}]})
2020-04-29T14:44:52.839+0200 E QUERY [thread1] Error: couldn't add user: Cannot create users in the local database :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1437:15
@(shell):1:1
db.createUser({ user: "root", pwd: "pass", roles: [{role: "dbAdminAnyDatabase", db: "local"}]})
2020-04-29T14:45:32.230+0200 E QUERY [thread1] Error: couldn't add user: Cannot create users in the local database :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1437:15
@(shell):1:1
Тоже самое и для назначения ролиched to db adminм просто нет таких ролей. И создать их нельзя
> db.grantRolesToUser('root',[{role:"root",db:"local"}])
2020-04-29T14:48:21.148+0200 E QUERY [thread1] Error: No role named root@local :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.grantRolesToUser@src/mongo/shell/db.js:1640:19
@(shell):1:1
Та
DS
y
DS
y
y
y
y
y
y
y
y