Rmongodb support for MongoDB 3

I am creating an R script in which I need to connect to MongoDB via authentication and process data retrieved from the database using rmongodb . For this, I created a new MongoDB user in version 3.0.4 and when connecting to mongoDB from an R script authentication. Also the user is successfully authenticated through the mongo shell. Also the authentication works fine as long as I authenticate the user created in MongoDB version 2.x.

Below is the code snippet we used in R script to connect to Mongo database.

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

When executing the above code snippet, we get the following response

Error: Loading required package: rmongodb Authentication failed.

Please suggest me a suitable solution for the authentication error in the rmongodb package.

+3


source to share


2 answers


rmongodb

(as in 1.8.0) uses the legacy MongoDB C driver, which does not yet have full MongoDB 3.0 support. In particular, it will not support the use of the new SCRAM-SHA-1 authentication or the optional WiredTiger storage engine.

There is an issue on Github rmongodb

tracking this: MongoDB version 3.0 compatibility .



Until rmongodb

updated, your options (in order of least trouble) include:

  • use another driver that has MongoDB 3.x support (i.e. RMongo 0.1.0 or newer )

  • use MongoDB 2.6

  • use MongoDB 3.x, but move to an earlier version of MONGO-CR (and don't use WiredTiger or any alternative storage engines)

+4


source


After going through this myself I thought I'd add my two cents in case it helps someone.

@Stennie is on the right track with authentication stuff. So, if you want to use mongo 3, then the way to do it is as follows (this is from ubuntu installation).



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

should work now! Hope this helps someone ...

+3


source







All Articles