简体   繁体   中英

not authorized for query on admin.system.users - first user created

I have a sharded cluster on mongo (3 replica sets, each one with three nodes). All mongod`s are running with keyFile option.
To see all the users on the data base:

$ mongo --port XXXXX -u USER -p PASSWORD admin <br>
MongoDB shell version: 2.4.12<br>
connecting to: 127.0.0.1:XXXXX/admin<br>
mongos> use admin<br>
switched to db admin<br>
mongos> show users<br>
Tue Dec 16 01:46:17.763 error: { "$err" : "not authorized for query on   
admin.system.users", "code" : 16549 } at src/mongo/shell/query.js:128<br>mongos><br>

I think I wrongly created the first user administrator with not enough privileges. Is that so? How do I see the privileges of current mongo user? What should I do to fix this?

Your user does not have necessary privileges.

db.grantRolesToUser("username", [ { role : "clusterAdmin", db: "admin" } ] )

From mongodb documentation :

If users exist in the MongoDB database, but none of them has the appropriate prerequisites to create a new user or you do not have access to them, you must restart mongod with the --noauth option. First User Restrictions

You may also need to read Enable Authentication in a Sharded Cluster

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM