I am building a R script in which I need to connect to MongoDB through authentication and process the data fetched from database using rmongodb package.For that I have created a new MongoDB user in version 3.0.4 and while connecting to mongoDB from R script authentication fails. Also the user is authenticated successfully through mongo shell. Also authentication works fine while I authenticate user created in MongoDB version 2.x.
Following is code snippet which we have used in R script to connect to Mongo database.
mongo <- mongo.create("127.0.0.1", "", "user", "pass", "db", 0L )
While executing above code snippet we receive the following response
error: Loading required package: rmongodb Authentication failed.
Please suggest me appropriate solution to authentication failure issue in rmongodb package.
rmongodb
(as at 1.8.0) uses a legacy MongoDB C driver which doesn't have full support for MongoDB 3.0 yet. In particular, it will not support using the new SCRAM-SHA-1 default authentication or optional WiredTiger storage engine.There's an
rmongodb
issue in Github tracking this: Compatibility with version 3.0 of MongoDB.Until
rmongodb
is updated your options (in order of least to most hasslesome) include:use a different driver which does have MongoDB 3.x support (i.e. RMongo 0.1.0 or newer)
use MongoDB 2.6
use MongoDB 3.x but downgrade to the older MONGO-CR auth (and do not use WiredTiger or any alternative storage engines)