On this page本页内容
authenticate
Authenticates using the x.509 authentication mechanism. 使用x.509身份验证机制进行身份验证。When using 使用mongosh
, use the db.auth()
helper as follows:mongosh
时,使用db.auth()
助手,如下所示:
Starting in version 4.2 of the 从mongoshell的4.2版开始,您可以将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. passwordPrompt()
方法与各种用户身份验证/管理方法/命令结合使用,提示输入密码,而不是直接在方法/命令调用中指定密码。However, you can still specify the password directly as you would with earlier versions of the 但是,您仍然可以像使用早期版本的mongo
shell.mongo
shell那样直接指定密码。
db.auth( "username", passwordPrompt() )
In earlier versions, to use the 在早期版本中,要使用db.auth()
method, specify the password:db.auth()
方法,请指定密码:
db.auth( "username", "password" )
Starting in MongoDB 4.2, if the client that issued the 从MongoDB 4.2开始,如果发出authenticate
disconnects before the operation completes, MongoDB marks the authenticate
for termination (i.e. killOp
on the operation).authenticate
的客户端在操作完成之前断开连接,MongoDB会将authenticate
标记为终止(即操作上的killOp
)。