정의
passwordPrompt()Prompts for the password in
mongosh. The entered password is not displayed in the shell. UsepasswordPrompt()in conjunction with methods that accept password as a parameter instead of specifying the password in cleartext to those methods.
예시
와 함께 사용 passwordPrompt() db.createUser()
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" ] } )
메시지가 표시되면 비밀번호를 입력합니다.
와 함께 사용 passwordPrompt() db.auth()
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")
와 함께 사용 passwordPrompt() db.changeUserPassword()
db.changeUserPassword() 에서는 비밀번호를 지정해야 합니다.
You can use passwordPrompt() instead of specifying the password.
db.changeUserPassword("user123", passwordPrompt())
메시지가 표시되면 비밀번호를 입력합니다.
와 함께 사용 passwordPrompt() db.updateUser()
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" ] } )
메시지가 표시되면 비밀번호를 입력합니다.