3

我正在构建一个R 脚本,其中我需要通过身份验证连接到MongoDB ,并使用rmongodb包处理从数据库中获取的数据。为此,我在3.0.4 版本中创建了一个新的 MongoDB 用户,同时从R 脚本身份验证连接到 mongoDB失败。此外,用户通过 mongo shell 成功验证。当我对在 MongoDB 2.x 版中创建的用户进行身份验证时,身份验证也可以正常工作。

以下是我们在 R 脚本中用于连接 Mongo 数据库的代码片段。

mongo <- mongo.create("127.0.0.1", "", "user", "pass", "db", 0L )

在执行上述代码片段时,我们收到以下响应

错误:加载所需的包:rmongodb 身份验证失败。

请建议我适当的解决方案来解决 rmongodb 包中的身份验证失败问题。

4

2 回答 2

4

rmongodb(从 1.8.0 开始)使用旧的 MongoDB C 驱动程序,它还没有完全支持 MongoDB 3.0。特别是,它不支持使用新的 SCRAM-SHA-1 默认身份验证或可选的 WiredTiger 存储引擎。

rmongodbGithub 中跟踪此问题存在一个问题: Compatibility with version 3.0 of MongoDB

rmongodb更新之前,您的选项(按最麻烦到最少的顺序)包括:

  • 使用支持 MongoDB 3.x 的不同驱动程序(即RMongo 0.1.0 或更新版本

  • 使用 MongoDB 2.6

  • 使用 MongoDB 3.x 但降级到旧的 MONGO-CR 身份验证(并且不要使用 WiredTiger 或任何替代存储引擎)

于 2015-06-26T08:23:39.083 回答
3

我自己刚刚经历过这个,我想我会加两分钱,以防它帮助别人。

@Stennie 是正确的目标与身份验证的东西。因此,如果您想使用 mongo 3,其运行方式如下(这是来自 ubuntu 安装)。

1) sudo nano /etc/mongod.conf 2) Comment out the "auth=TRUE" line 3) sudo service mongod restart 4) login to mongo shell (now with no authentication so everything is open) 5) use admin 6) Execute the following: var schema = db.system.version.findOne({"_id" : "authSchema"}) schema.currentVersion = 3 db.system.version.save(schema) (the above 3 commands are from here: https://jira.mongodb.org/browse/SERVER-17459) 7) create your users in the appropriate database 8) to make sure the right credentials are set up, type db.system.users.find() and amke sure they have the MONGODB-CR credentials 9) quit mongo 10) ucomment out the authentication line in /etc/mongod.conf 11) restart mongodb using sudo service mongod restart

现在应该工作了!我希望对某人有所帮助...

于 2015-07-28T05:05:11.807 回答