정의
db.changeUserPassword(username, password)사용자의 비밀번호를 업데이트합니다. 사용자가 정의된 데이터베이스, 즉 사용자를
created로 지정한 데이터베이스에서 메서드를 실행합니다.중요
Mongo쉬 방법
This page documents a
mongoshmethod. This is not the documentation for database commands or language-specific drivers, such as Node.js.데이터베이스 명령에 대해서는
updateUser명령을 참조하십시오.MongoDB API 드라이버의 경우 언어별 MongoDB 드라이버 설명서를 참조하세요.
Parameter유형설명username문자열
비밀번호를 변경하려는 사용자의 이름입니다.
password문자열
사용자의 비밀번호입니다. 값은 다음 중 하나일 수 있습니다.
일반 텍스트 문자열로 된 사용자의 비밀번호
passwordPrompt()은(는) 사용자의 비밀번호를 묻는 메시지를 표시합니다.메서드/명령 호출에서 암호를 직접 지정하는 대신
passwordPrompt()메서드를 다양한 사용자 인증/관리 메서드/명령과 함께 사용하여 암호를 묻는 메시지를 표시할 수 있습니다. 그러나 이전 버전의mongo셸에서와 마찬가지로 비밀번호를 직접 지정할 수도 있습니다.
writeConcern문서
호환성
이 메서드는 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
중요
이 명령은 MongoDB Atlas 클러스터에서 지원되지 않습니다. 모든 명령에 대한 Atlas 지원에 관해 자세히 알아보려면 지원되지 않는 명령을 참조하세요.
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
필요한 액세스 권한
데이터베이스에서 다른 사용자의 비밀번호를 수정하려면 해당 데이터베이스에 changePassword 조치가 있어야 합니다.
행동
경고
By default, db.changeUserPassword() sends all specified data to the MongoDB instance in cleartext, even if using passwordPrompt(). Use TLS transport encryption to protect communications between clients and the server, including the password sent by db.changeUserPassword(). For instructions on enabling TLS transport encryption, see Configure MongoDB Instances for TLS/SSL Encryption.
MongoDB는 비밀번호를 일반 텍스트로 저장하지 않습니다. 비밀번호는 클라이언트와 서버 간의 전송 시 그리고 TLS 전송 암호화가 활성화되지 않은 경우에만 취약합니다.
예시
다음 작업은 products 데이터베이스에서 accountUser 라는 사용자의 비밀번호를 SOh3TbYhx8ypJPxmt1oOfL로 변경합니다.
팁
메서드/명령 호출에서 암호를 직접 지정하는 대신 passwordPrompt() 메서드를 다양한 사용자 인증/관리 메서드/명령과 함께 사용하여 암호를 묻는 메시지를 표시할 수 있습니다. 그러나 이전 버전의 mongo 셸에서와 마찬가지로 비밀번호를 직접 지정할 수도 있습니다.
use products db.changeUserPassword("accountUser", passwordPrompt())
When prompted in mongosh for the password, enter the new password.
You can also pass the new password directly to db.changeUserPassword():
use products db.changeUserPassword("accountUser", "SOh3TbYhx8ypJPxmt1oOfL")