I'm trying to connect into mongodb with pymongo, but i can't import data or create a collection.
This is the code to connect into mongo :
db_local = pymongo.MongoClient("mongodb://mongodb-service.default.svc.cluster.local:27017", username="admin", password="pass")
mydb_local= db_local["test"]
And then i tried this to create new collection :
mydb_local.create_collection("HDFS"]
While trying to add the collection i get this error :
Authentification failed., full error: {'ok': 0.0, 'errmsg': Authentification failed.', 'code : 18, 'codeName': AuthentificationFailed'}
Meanwhile, i deployed Mongodb into Minikube, and this is the mongodb-sercret.yaml file :
apiVersion : v1
kind: Secret
metadata:
name: mongodb-secret
type: Opaque
data :
mongo-root-username : dXNlcm5hbWU=
mongo-root-password : cGFzc3dvcmQ=
PLease try this :
db_local= pymongo.MongoClient("mongodb://admin:pass@mongodb-service.default.svc.cluster.local:27017")