I'm trying to execute the below commands taken from the mongoDB docs

use admin
db.system.version.find( { _id: "authSchema" })

But running those in Robo 3t gives the following output

switched to db admin

Error: error: { 
"$err" : "not authorized for query on admin.system.version", "code" : 13 

The user I'm logged in with has the dbOwner role.

Some people suggest granting the root role to the user, but this fails, saying 'not authorized'

    [ "readWrite" , { role: "root", db: "admin" } ]

It seems like a bad idea to grant root access just for this one query anyways, but I don't see any better solution.

So, how does one query the admin database in mongoDB?

(Current mongoDB version is 2.6.11)

  • The dbOwner role will only grant permissions on a single database. If the user is a dbOwner on foo, it will be able to create other users that can read foo, but will not be able to grant permissions on the admin database. You will need a user with permissions on admin to grant a role to your user. Commented Jul 31, 2018 at 16:45

1 Answer 1


As per your log statement you are getting the error message such as

Error: error: { 
"$err" : "not authorized for query on admin.system.version", "code" : 13 

As github mongodb documentation here error_code("Unauthorized", 13).

As per MongoDB documentation here MongoDB grants access to data and commands through role-based authorization and provides built-in roles that provide the different levels of access commonly needed in a database system. You can additionally create user-defined roles.

A role grants privileges to perform sets of actions on defined resources. A given role applies to the database on which it is defined and can grant access down to a collection level of granularity.

You need to assign the read role or readWrite to the user.

For example :

Create Administrative User with Roles

use admin
     user: "appAdmin",
     pwd: "password",
         { role: "readWrite", db: "config" }


For further your ref here, here and here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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