C100DEV Drivers, Tools, Transactions, and Search Practice Question
A developer is using mongosh to connect to a MongoDB Atlas cluster and needs to run several administrative commands. The developer wants to ensure that the connection uses the correct authentication database and that all commands are executed with the appropriate read preference. Which mongosh command-line option should be used to specify the authentication database?
⚠ Common exam trap
A common mix-up: candidates confuse the authentication database with the default database to use after connection.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
--authenticationDatabase
In mongosh, the --authenticationDatabase option explicitly sets the database used for authentication. This is necessary when user credentials reside in a database other than the default (often admin). Other options like --db or --readPreference affect connection behavior but not authentication. Specifying the correct authentication database ensures that the provided username and password are validated against the intended database.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
--readPreference
Why it's wrong here
--readPreference sets the read preference for the connection, such as primary or secondaryPreferred. While it affects how reads are routed, it does not influence authentication. The scenario requires specifying the authentication database, not the read preference, so this option is irrelevant to the stated goal.
- ✗
--username
Why it's wrong here
--username provides the username for authentication but does not specify the database where the credentials are stored. Without the correct authentication database, the username alone may not authenticate successfully. The question asks for the option to set the authentication database, not the username.
- ✗
--db
Why it's wrong here
--db specifies the default database to use after connecting, but it does not control authentication. Authentication occurs against the database where the user is defined, which may be different. Using --db would change the context for subsequent commands but would not resolve authentication failures if the wrong authentication database is used.
- ✓
--authenticationDatabase
Why this is correct
The --authenticationDatabase option in mongosh specifies the database against which the user is authenticated. This is essential when the user credentials are stored in a database other than the default (e.g., admin). Without it, authentication may fail if the user is not defined in the default database. It directly addresses the requirement to set the correct authentication database.
About these practice questions
One of 259 original C100DEV practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official MongoDB exam blueprint
This C100DEV practice question is part of Courseiva's free MongoDB certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the C100DEV exam.