- Reference >
- Database Commands >
- Authentication Commands >
- authenticate
authenticate¶
On this page
-
authenticate
¶ Authenticates using the x.509 authentication mechanism. When using the
mongo
shell, use thedb.auth()
helper as follows:Tip
Starting in version 4.2 of the
mongo
shell, you can use thepasswordPrompt()
method in conjunction with various user authentication/management methods/commands to prompt for the password instead of specifying the password directly in the method/command call. However, you can still specify the password directly as you would with earlier versions of themongo
shell.In earlier versions, to use the
db.auth()
method, specify the password:
Behavior¶
Client Disconnection¶
Starting in MongoDB 4.2, if the client that issued the authenticate
disconnects before the operation completes, MongoDB marks
the authenticate
for termination (i.e. killOp
on the
operation).