Maulik Shah
Maulik Shah

Reputation: 11

how to update or change roles of default admin user on Mongodb once its created?

I just setup a 3 node MongdoDB cluster with replicasets and made a novice mistake. I setup the replica set etc first and then was being fancy and setup the default admin user as below:

show users { "_id" : ObjectId("blah"), "user" : "admin", "pwd" : "blah", "roles" : [ "userAdminAnyDatabase" ] }

This is fine for basic admin but I cannot do any replica set commands as the role is not cluster admin:

rs.status() { "ok" : 0, "errmsg" : "unauthorized" }

I tried a few things

Any other thoughts on this one - outside of redoing the setup for mongo?

Upvotes: 1

Views: 3165

Answers (1)

BZapper
BZapper

Reputation: 330

You'll need to add "clusterAdmin" role to your admin user, more doc can be found here

Upvotes: 1

Related Questions