iIdropped all users with a useradminanydatabase

Hi, I’m new to mongodb I installed the community version, and I’m trying to play around to have a feel, I used a config file and enabled security, I created my first user and gave it a role of userAdminAnyDatabase, now I used db.dropAllUsers() now I can’t do my role as userAdminAnydatabase when I login because Ive mistakenly removed all users, please what can I do

Which db you were connected when you dropped all users?
dropallusers will drop all users of current db
Disable auth/security in your config,bounce your mongod create new admin user and enable security again

Hi Ramachandra_Tummala, thanks for responding, I tried your suggestion it didn’t work, concerning your question on the database where I dropped all users (admin Database).
I removed the security settings in my config file, created a user, added back the security setting but still can’t run commands like show dbs. Kindly throw more light

Were you able to login successfully authenticating against admin db?
May be the role you have given to the user do not have list dbs privilege
Give readWrite privilege or other built in roles


Thanks alot Ramachandra_Tummala, it worked!!! :grinning: :grinning:

1 Like