AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

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" ]
}
)

パスワードの入力を求められたら、入力します。

このページを評価

項目一覧