nerdexam
MongoDB

C100DBA · Question #106

To add a new user and enable authentication in MongoDB, which of the following steps need be executed?

The correct answer is C. update users collection and restart mongodb with -auth option. Option C is correct because MongoDB's security model requires two steps: first, creating the user by updating the users collection (via db.createUser()), and then restarting MongoDB with the --auth flag to enforce authentication on connections. Without the --auth startup option,

Security

Question

To add a new user and enable authentication in MongoDB, which of the following steps need be executed?

Options

  • Aupdate users collection and restart mongodb
  • BAll of the above
  • Cupdate users collection and restart mongodb with -auth option
  • Dupdate users collection and run db.enableAuthenticationQ

How the community answered

(18 responses)
  • A
    6% (1)
  • B
    6% (1)
  • C
    89% (16)

Explanation

Option C is correct because MongoDB's security model requires two steps: first, creating the user by updating the users collection (via db.createUser()), and then restarting MongoDB with the --auth flag to enforce authentication on connections. Without the --auth startup option, MongoDB runs in open mode and ignores credentials entirely.

Why the distractors fail:

  • A - Restarting without --auth leaves authentication disabled; MongoDB simply ignores the users you created.
  • D - db.enableAuthentication() is not a real MongoDB command; authentication is a server-level setting controlled at startup, not from the shell.
  • B - "All of the above" is wrong because A and D are both incorrect methods.

Memory tip: Think of it as a two-lock system - you must set the lock (create the user) and turn the key (start with --auth). Either step alone leaves the door open.

Topics

#authentication#user management#mongod startup options

Community Discussion

No community discussion yet for this question.

Full C100DBA Practice