首页 > 解决方案 > 无法将 Django 与 mongoDb 连接

问题描述

我正在使用 djongo 将我的 mongodb 与 django 连接起来。我使用的 mongodb 是 atlas service.my 密码和用户名是正确的,即使它显示身份验证失败。

System check identified some issues: 
    sock_info.check_auth(all_credentials)
  File "C:\Users\rupek\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\pool.py", line 712, in check_auth
    auth.authenticate(credentials, self)
  File "C:\Users\rupek\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\auth.py", line 564, in authenticate
    auth_func(credentials, sock_info)
  File "C:\Users\rupek\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\auth.py", line 263, in _authenticate_scram
    res = sock_info.command(source, cmd)
  File "C:\Users\rupek\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\pool.py", line 603, in command
    return command(self.sock, dbname, spec, slave_ok,
  File "C:\Users\rupek\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\network.py", line 165, in command
    helpers._check_command_response(
  File "C:\Users\rupek\AppData\Local\Programs\Python\Python38\lib\site-packages\pymongo\helpers.py", line 159, in _check_command_response
    raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: Authentication failed.

我的 setting.py 文件

'ENGINE': 'djongo',
        'NAME': 'first',
        'ENFORCE_SCHEMA': False,
        'CLIENT': {
            'host': 'mongodb+srv://user:pass@cluster0-omtoq.mongodb.net/test?retryWrites=true&w=majority',
            'port': 27017,
            'username': 'user',
            'password': 'pass',
            'authSource': 'first',
            'authMechanism': 'SCRAM-SHA-1'
        },

提前致谢

标签: pythondjangomongodbbackenddjongo

解决方案


推荐阅读