Sharded cluster instance(Node) getting authentication error

Hi Fabio_Ramohitaj

First of all Thanks for your guidance and responses.

Actually, I have followed the Link to create “shard-local administrator” on Mongod instance using below query.

admin = db.getSiblingDB("admin")
admin.createUser(
  {
    user: "fred",
    pwd: "changeme1",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)

After that wrongly update the role on this same user using below query

db.updateUser(
...   {
...     user: "fred",
...     pwd: "changeme1",
...     roles: [ { role: "dbAdmin", db: "mydb" } ]
...   }
... )

After that getting error while running db.getUsers()
“Error: not authorized on admin to execute command”

I am not able to drop the user as well.

Please Guide me to fix the issue.

Hi @Nino_I ,
Are you authenticated with the the user that have the correct privileges in the correct resource?

From the documentation:

BR

Thanks Fabio_Ramohitaj let me try and update.

1 Like