2 / 7
Aug 2024

Enterprise admin> db.shutdownServer()
MongoServerError[Unauthorized]: not authorized on admin to execute command { shutdown: 1, lsid: { id: UUID(“155e6af9-4094-46c6-b6fd-3694afcaacf5”) }, $db: “admin” }

Enterprise admin> db.getUsers()
{
users: [
{
_id: ‘admin.admin’,
userId: UUID(‘6817e89a-c4de-433c-bb81-f9eaf4b76162’),
user: ‘admin’,
db: ‘admin’,
roles: [
{ role: ‘userAdminAnyDatabase’, db: ‘admin’ },
{ role: ‘dbAdminAnyDatabase’, db: ‘admin’ },
{ role: ‘readWriteAnyDatabase’, db: ‘admin’ }
],
mechanisms: [ ‘SCRAM-SHA-1’, ‘SCRAM-SHA-256’ ]
}
],
ok: 1
}

Why i can not execute this command?

Thanks.
David

Thanks for the reply but if i disabled security in the mongod.conf file, it works.

David

Yes, it works. But it also means anyone who connect to your server can do it, anyone who connect to your server can modify and delete all your data.

What am i saying if i enabled security in the mongod.conf file, it will not work

database administrators are not server administrators, and this shutdown operation requires the latter one.

let me give you one needle from the haystack: the page section Fabio linked above gives “hostManager” as an example. check below link and see what other built-in roles you may use, or surf the nearby topics on the left for the permissions you may assign to a custom one.