mongosh --username app --password secret --authenticationDatabase admin appdb

Category: Databases & SQL

mongosh --username app --password secret --authenticationDatabase admin appdb

Connect with explicit credentials

Authenticates as app against the admin database, where MongoDB stores user definitions, then connects to appdb. The same flags work for mongodump and mongoexport. Prefer environment variables or a config file over visible passwords.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.