Docs Menu

Docs HomeMongoDB Manual

authenticate

On this page

  • Behavior
authenticate

Authenticates using the x.509 authentication mechanism. When using mongosh, use the db.auth() helper as follows:

Tip

Starting in version 4.2 of the mongo shell, you can use the passwordPrompt() 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 the mongo shell.

db.auth( "username", passwordPrompt() )

In earlier versions, to use the db.auth() method, specify the password:

db.auth( "username", "password" )

Tip

See:

Starting in MongoDB 4.2, if the client that issued authenticate disconnects before the operation completes, MongoDB marks authenticate for termination using killOp.

←  Authentication Commandsgetnonce →

On this page

Share Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.