Database Reference
In-Depth Information
Sun May 26 17:22:26.132 JavaScript execution failed: error: {
"$err" : "not authorized for query on admin.system.namespaces",
"code" : 16550
} at src/mongo/shell/query.js:L131 }
>db.auth("admin", "pass");
1
At this point, the mongo console will print either 1 (successful authentication) or 0 (a failed authentication):
1
>show collections
system.indexes
system.users
If your authentication was successful, you will be able to perform any operations available based on your user
permissions.
If your authentication was unsuccessful, then you need to check whether your username/password is correct and
whether the admin user has been correctly added to the admin database. Reset your server so it has no authentication,
and then use the following command to list the contents of the system.users collection in the admin database:
$mongo
>use admin
> db.system.users.find()
{ "_id" : ObjectId("5239915b1ce3dc1efebb3c84"), "user" : "admin", "pwd" :
"e4e538f5dcb52537cad02bbf8491693c", "roles" : [ "readWrite", "dbAdmin" ] }
if you are using an admin credential to access databases other than admin , then you must first authenticate
against the admin database. otherwise, you will not be able to access any other databases in the system.
Note
The mongo console shows the contents of the user collection, enabling you to see what the userid is, while the
password is shown as an MD5 hash of the original password you supplied:
$ mongo
> use blog
switched to db blog
> show collections
Wed Sep 18 21:42:51.855 JavaScript execution failed: error: {
"$err" : "not authorized for query on blog.system.namespaces",
"code" : 13
} at src/mongo/shell/query.js:L128
> db.auth("admin","pass")
Error: 18 { code: 18, ok: 0.0, errmsg: "auth fails" }
0
> use admin
switched to db admin
> db.auth("admin","pass")
1
 
Search WWH ::




Custom Search