mongodb on kubernetes user and password Authentication failed
kubectl create -f https://raw.githubusercontent.com/piomin/sample-spring-boot-on-kubernetes/master/k8s/mongodb-deployment.yaml
waitting...
➜ kubernetes git:(master) ✗ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
mongodb-7d49f8dbb7-6lj9h 1/1 Running 0 27s 172.17.0.3 minikube <none> <none>
kubectl exec -it mongodb-7d49f8dbb7-6lj9h bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
root@mongodb-7d49f8dbb7-6lj9h:/# mongosh
Current Mongosh Log ID: 61df98f4e11d99416ba76c7c
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000
Using MongoDB: 5.0.5
Using Mongosh: 1.1.7
test> db.auth('dGVzdA==','UGlvdF8xMjM=')
MongoServerError: Authentication failed.
test> use admin
switched to db admin
admin> db.auth('dGVzdA==','UGlvdF8xMjM=')
MongoServerError: Authentication failed.
i hope login successful.
CodePudding user response:
You pass BASE64 encoded strings
db.auth('dGVzdA==','UGlvdF8xMjM=')
must be
db.auth('test','Piot_123')
(and change your password as soon as possible, because now it is public)
