Navigation
This version of the documentation is archived and no longer supported.

db.auth()

db.auth("username", "password")
Parameters:
  • username (string) – Specifies an existing username with access privileges for this database.
  • password (string) – Specifies the corresponding password.

Allows a user to authenticate to the database from within the shell. Alternatively use mongo --username and --password to specify authentication credentials.