python - 无法将 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'
},
提前致谢
解决方案
推荐阅读
- python - 如果没有进行任何更改,如何防止 Django 表单保存?
- ios - 可以使用 Xcode 11 beta 6 在 AppStore 中提交应用程序吗?
- r - 将 MMM-YY 转换为 1968 年之前的日期
- flutter - Flutter 中的 FloatingActionButton onLongPress 监听器
- python - 如何根据另一个数据框中的值更改一个数据框中的值?
- google-bigquery - BigQuery 给出不一致的结果
- jquery - Bootstrap modal pop 将成为 iframe 的顶部
- python - 在 tensorflow 的急切执行训练期间修复部分变量
- go-modules - 如何验证来自 Bash 的 go.sum 模块哈希?
- javascript - 如何用 jquery 修复 tfoot