patternModerate
db.serverStatus() got not authorized on admin to execute command
Viewed 0 times
gotadminserverstatuscommandnotauthorizedexecute
Problem
My mongo version : 2.6.11
I want to check
But got errmsg:
How can I add authorization ??
I find a command can create user with authorization :
But I don't know which is
How can I authorize it??
I want to check
db.serverStatus() in my robomomgoBut got errmsg:
{
"ok" : 0,
"errmsg" : "not authorized on admin to execute command { serverStatus: 1.0 }",
"code" : 13
}How can I add authorization ??
I find a command can create user with authorization :
db.createUser(
{
user: "tester",
pwd: "password",
roles: [
{ role: "readWrite", db: "test" }
]
}
);But I don't know which is
db.serverStatus() 's database name??How can I authorize it??
Solution
You need to grant the
Here's a list of other clusterMonitor roles
clusterMonitor role to the user running the db.serverStatus command. You can grant this role to a user by calling the `grantRolestoUser.Here's a list of other clusterMonitor roles
use admin
db.createUser(
{
user: "clustermonitor",
pwd: "password",
roles: [
{ role: "readWrite", db: "admin" }
]
}
);
db.grantRolesToUser(
"clusterMonitor",
[
{ role: "clusterMonitor", db:"admin"}
]
);Code Snippets
use admin
db.createUser(
{
user: "clustermonitor",
pwd: "password",
roles: [
{ role: "readWrite", db: "admin" }
]
}
);
db.grantRolesToUser(
"clusterMonitor",
[
{ role: "clusterMonitor", db:"admin"}
]
);Context
StackExchange Database Administrators Q#121832, answer score: 16
Revisions (0)
No revisions yet.