Have clusterManager, can't delete db

admin> db.grantRolesToUser("admin", [ {role: "clusterManager", db: 'admin'}]);
{ ok: 1 }
admin> use mydb
switched to db mydb
mydb> db.dropDatabase();
MongoServerError: not authorized on mydb to execute command { dropDatabase: 1

How do I set admin up to dropDatabase() ?

Pretty amazing that the article on dropDatabase() doesn’t mention the roles needed to do so.

1 Like

Found it, not in MongoDB docs, but studio3t

db.grantRolesToUser("admin", [ {role: "dbAdminAnyDatabase", db: 'admin'}]);

Hi @Jack_Woehr

The information you’re looking for is documented in the Built-In Roles page :slight_smile: . Specifically, dropDatabase needs clusterAdmin, dbAdmin, or dbAdminAnyDatabase role.

Best regards

Hi @kevinadi … thank you. However, a search in the docs for dropDatabase doesn’t point to any role information, nor does the dropDatabase article mention that the role is required. Seems like the documentation should mention roles required.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.