- Reference >
- JavaScript Methods >
- db.auth()
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.