我有一个 value.yaml 文件来部署 mongo pod,如下所示:
mongodb:
replicaCount: 1
image:
repository: bitnami/mongodb
tag: "5.0"
pullPolicy: IfNotPresent
service:
port: 27017
architecture: standalone
persistence:
enabled: true
existingClaim: "mongo-volume-claim"
# Additional pod annotations
podAnnotations: {}
# MongoDB credentials
auth:
enabled: true
rootPassword: pass@123
我执行到 MongoDB pod,然后运行命令进行连接,我遇到如下问题:
mongodb-5c4b9b4659-8chzx:/$ mongosh --host 127.0.0.1 --authenticationDatabase admin -u root -p pass@123
Current Mongosh Log ID: 65a02b66abc6a4a15bd3535e
Connecting to: mongodb://<credentials>@127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&authSource=admin&appName=mongosh+2.1.1
MongoServerError: Authentication failed.
有什么建议请告诉我!
您可能没有在 MongoDB Helm 图表的 value.yaml 文件中指定根用户名。默认情况下,用户名通常设置为 root,但最好在配置中明确定义它。
通过在 auth 部分下添加 rootUser 字段来更新 value.yaml:
mongodb:
replicaCount: 1
image:
repository: bitnami/mongodb
tag: "5.0"
pullPolicy: IfNotPresent
service:
port: 27017
architecture: standalone
persistence:
enabled: true
existingClaim: "mongo-volume-claim"
# Additional pod annotations
podAnnotations: {}
# MongoDB credentials
auth:
enabled: true
rootUser: root
rootPassword: pass@123
更新文件后,使用更新的配置重新部署 MongoDB 实例。