You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS DocumentDB/MongoDB集群连接报错301及Compass无法连接如何解决?

解决方案

你需要调整连接参数,适配Amazon DocumentDB的认证和TLS配置要求:

  • 错误代码301对应Unsupported mechanism,原因是Amazon DocumentDB仅支持SCRAM-SHA-1认证机制,而新版MongoDB客户端默认会优先使用SCRAM-SHA-256尝试认证,该机制不被DocumentDB支持,需要手动指定认证机制。
  • 你已经关闭了集群的TLS功能,需要在连接参数中显式禁用TLS,否则客户端会默认发起TLS握手导致连接失败。

命令行连接调整

在原有命令末尾追加两个参数即可,修改后命令如下:

mongo --host docdb-yyy-mm-dd.cluster-name-of-cluster.us-east-1.docdb.amazonaws.com:27017 --username <myUser> --password <insertYourPassword> --authenticationMechanism SCRAM-SHA-1 --tls=false

如果使用6.x及以上版本的MongoDB Shell,将命令开头的mongo替换为mongosh即可,其余参数不变。

MongoDB Compass连接串调整

在原有连接串的查询参数末尾追加authMechanism=SCRAM-SHA-1和tls=false即可,修改后连接串如下:

mongodb://<userName>:<insertYourPassword>@docdb-yyy-mm-dd.cluster-name-of-cluster.us-east-1.docdb.amazonaws.com:27017/?replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false&authMechanism=SCRAM-SHA-1&tls=false

内容的提问来源于stack exchange,提问作者Aerodynamika

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 22:45:05