0
votes

I am using Mongo 2.4.

I had a single user in the Admin db, and added the role "clusterAdmin", when I meant to add the "userAdmin" role. Now I can't execute any user-admin based operations.

I tried to update and remove the user, as well as add a new user with "userAdmin" privileges, but because the "clusterAdmin" role does not have privileges to the users collection, I'm out of luck.

How do I bypass the security to add a new user in the Admin db, with "userAdmin" privileges or remove the current "admin" user with only "clusterAdmin" privileges?

1
One option can be: Run mongod without auth mode, and then make those changes. And again restart mongod on auth modeAbhishek Kumar

1 Answers

0
votes

happened to me a lot, so I could solve it, remove all Admin users using:

use admin
db.system.users.remove();

and add a new one as admin

db.addUser("name","name);
db.auth("name","name");

then you create a user with role clusterAdmin

but you will have to login as admin to do

mongo -port 27017 -u name -p name admin