pymongo auth failed in python script

后端 未结 4 2083
不知归路
不知归路 2020-12-31 00:44

I have installed mongodb and enabled auth. and its working find. I can connect it from remote notebook using robomongo application:

Host: SERVER_IP
PORT: 270         


        
4条回答
  •  再見小時候
    2020-12-31 00:56

    For pymongo,

    Try below for MongoDB 4:

    Add authSource : This is the name of the database that has the collection with the user credentials.

    Ex:

    client = MongoClient(host=<>,
                         port=<>, 
                         username=<>, 
                         password=<>,
                        authSource="admin")
    db_obj = client[db_name]
    

    Edit 1: I have tried this on Mongo 3.x version as well. Working for that too.

提交回复
热议问题