Root account - dumb question

Is the root user a reserved account? That is, MongoDB knows a root username is a privileged account.

It depends.

On Linux and Unix, root is a special account. In MongoDB, it is not. In MongoDB, the authorization a user get depends of its roles.

1 Like

Thanks steevej,

Yeah, just trying to get around to whether it is really a ‘generic’ account like on *nix. It does sound like a built-in role though, isnt’ it? Or it is not too :frowning:

It is not generic it is special:

https://mediatemple.net/community/products/dv/204643890/an-introduction-to-the-root-user

As far as i understand ‘root’ is just a “syntactic sugar” that comprehend all top-level roles ( mongodb - built in roles ):

  • readWriteAnyDatabase
  • userAdminAnyDatabase
  • clusterAdmin
  • restore
  • backup

Basically it allows you to avoid write this:

db.createUser({
    user: 'jhon'
    pwd: 'doe'
    roles: [
      {role:"userAdminAnyDatabase"},
      {role: "dbAdminAnyDatabase"},
      {role: "readWriteAnyDatabase"},
      {role: "clusterAdmin"}
      {role: "backup"}
      {role: "restore"}
    ]

Just my understanding so far though, not 100% sure!

Thanks fellas, I am asking the question in the context of what it is on the M103 course when they show the command to create the m103-admin account and one of the role is root.

That seems to make me think there are privileges assigned to root and that root is a built-in role of some sort internal to MongoDB

mongo admin --host localhost:27000 --eval ’
db.createUser({
user: “m103-admin”,
pwd: “m103-pass”,
roles: [
{role: “root”, db: “admin”}
]
})

Sorry, I am a bit lost atm as just starting with MongoDB. It is a lot of take atm especially the commands and syntax :frowning:

Sorry if I mislead you with my link to the linux/unix root user.

What you wanted was:

https://docs.mongodb.com/manual/reference/built-in-roles/

Thanks @steevej-1495

All good, just really want to be clear about it actually.
Thanks for the link, that’s what am trying to clarify.

Things does get muddied up especially with multiple choice Quiz / Lab where the answer is not exact and debatable, sometimes there is a sanity to the wrong answer and there is always a lost in translation with interpreting a question.

At the end of the days, it’s not the 100% score but the pass I suppose.