1.navicat上connection页面截图
2.pymongo连接
# -*- coding:utf-8 -*-
import pymongo
host = 'xxx.xxx.xxx.xxx'
port = 123456
user_name = 'xxx'
user_pwd = 'xxx'
# collection名
coll_name = 'xxx'
mongo_client = pymongo.MongoClient(host, port)
db = mongo_client.admin
# 认证
db.authenticate(user_name, user_pwd)
# 需要用的的表需要在认证后用client单独去关联
mongo_db = mongo_client.dbname
mongo_coll = event_mongo_db[coll_name]
# 获取所有collections并打印,验证是否登录成功
coll_names = mongo_db.list_collection_names(session=None)
print(coll_names)