1

I wanted to create a user,and got authorize error.
So I modify the /etc/mongod.conf :

#auth=True

And then restart the mongo,and create the user on terminal :

use admin
db.createUser(
  {
    user: "superAdmin",
    pwd: "    ",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)

It was success,then I modify /etc/mongod.conf back to :

auth=True

And I use remote login with robomongo
And I want to check db.serverStatus().connections
But nothing happened?
How can I fix this? enter image description here

2

The userAdminAnyDatabase role does not grant access to run the serverStatus command. Your db.serverStatus() command is returning an authorization error and you are then referencing a non-existent connections property which results in the "no results to show" message.

You can confirm this by running db.serverStatus(), which should return something similar to the following if the current user is not authorized:

{
     "ok" : 0,
     "errmsg" : "not authorized on admin to execute command { serverStatus: 1.0 }",
     "code" : 13
}

To allow the serverStatus command you need to grant either a built-in role that includes this privilege (clusterMonitor or hostManager in MongoDB 2.6) or create a user-defined role if you want a more narrow scope.

For example, to create and grant a custom role to run serverStatus:

use admin
db.createRole({
    role: "serverStatus",
    privileges: [
        { resource: { cluster: true }, actions: [ "serverStatus" ] },
    ],
    roles: []
})

db.grantRolesToUser("superAdmin",["serverStatus"])

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.