Pass username, password, and auth database.
Section: Connect and navigate
Connect with authentication
bash
bash
mongosh "mongodb://dbuser:secret@localhost:27017/appdb?authSource=admin"Explanation
`authSource=admin` is common when the user is defined in the admin database.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Connect and navigate
Connect with a MongoDB URI
Connect directly with a full connection string.
Get collection names programmatically
Return an array of collection names.