Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB not authorized for query admin.system.users

I am bit new to MongoDb and I am using MongoDb v.2.4.Here the problem is that when I run the mongod with --auth parameter, even after authenticating I am not able to perform simple operations such as "show users". But works fine if I run mongod without --auth parameter.

> use admin
switched to db admin
> db.auth("dbadmin","mypassword")
1
> show users
**Thu Feb 27 16:50:17.695 error: { "$err" : "not authorized for query on admin.sys
tem.users", "code" : 16550 } at src/mongo/shell/query.js:128**
like image 953
AnonymousCoder Avatar asked Nov 30 '22 19:11

AnonymousCoder


1 Answers

> use admin
switched to db admin
> db.grantRolesToUser("your_admin_name" ,[ "root"])

This command will give you all privileges on any db as admin.

like image 116
sivi Avatar answered Dec 06 '22 11:12

sivi