对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

passwordPrompt()(mongosh方法)

passwordPrompt()

Prompts for the password in mongosh. The entered password is not displayed in the shell. Use passwordPrompt() in conjunction with methods that accept password as a parameter instead of specifying the password in cleartext to those methods.

db.createUser()要求指定密码。

You can use passwordPrompt() as the value for the pwd instead of specifying the password.

db.createUser( {
user:"user123",
pwd: passwordPrompt(), // Instead of specifying the password in cleartext
roles:[ "readWrite" ]
} )

根据提示输入密码。

When you run the db.auth(<username>, <password>) command you can replace the password with the passwordPrompt() method.

如果省略 db.auth(<username>, <password>) 命令中的密码,系统将提示用户输入密码。

以下示例提示用户输入未显示在shell中的密码:

db.auth("user123")

db.changeUserPassword()要求指定密码。

You can use passwordPrompt() instead of specifying the password.

db.changeUserPassword("user123", passwordPrompt())

根据提示输入密码。

使用db.updateUser()更改密码时,该方法要求指定密码。

You can use passwordPrompt() as the value for the pwd instead of specifying the password.

db.updateUser(
"user123",
{
pwd: passwordPrompt(),
mechanisms: [ "SCRAM-SHA-256" ]
}
)

根据提示输入密码。

给本页内容打分

在此页面上