我在使用 play-reactivemongo 连接到 MongoDB 3 时遇到问题,并且遇到了“'未授权查询 XXX'(代码 = 13)”问题。当 MongoDB 在没有 --auth 的情况下启动时,该程序运行得非常好。
数据库版本应为 3.0.4,如日志所示。
2015-10-24T15:58:09.868+0800 I CONTROL [initandlisten] db version v3.0.4
我使用了 0.11.7 版 play2-reactivemongo 插件。
libraryDependencies ++= Seq(
"org.reactivemongo" %% "play2-reactivemongo" % "0.11.7.play24",
我已经像这样在 mongodb.uri 中指定了 authMode。
mongodb.uri = "mongodb://postsUser:12345678@localhost:27017/posts?authMode=?authMode=scram-sha1&authSource=posts&rm.tcpNoDelay=true"
我在 mongodb.log 中发现了以下错误。
2015-10-24T16:41:24.977+0800 I ACCESS [conn105] Failed to authenticate postsUser@posts with mechanism MONGODB-CR: AuthenticationFailed MONGODB-CR credentials missing in the user document
为什么使用 MONGODB-CR 而不是 SCRAM-SHA-1?假设 SCRAM-SHA-1 应该是默认值,对吧?