tc / RMongo

R client to interface with MongoDB
102 stars 34 forks source link

Rmongo Database authentication #28

Open Ankitmaroo opened 10 years ago

Ankitmaroo commented 10 years ago

Hi I like to use RMongo for easier querying but having problems with connecting to database on mongo version 2.6.

The code i am to use to connect would be

port<- 27017 host <- 'SDMongo01' db<-'Services' user<-'svc' pass<-'XYZ' con <- mongoDbConnect(db,host,port) authenticated <-dbAuthenticate(con,user,pass) collection<-"SampleInformation" query1 <- '{}' query2<-'{"_id":0,"project_name":1}' data<- dbGetQueryForKeys(con,collection,query1,query2) Error in .jcall(rmongo.object@javaMongo, "S", "dbGetQuery", collection, : com.mongodb.MongoException: not authorized for query on Services-Metrics-Val.SampleInformation

But similiar query using rmongodb works.

mongo <- mongo.create(host = "SDMongo01", username = "svc", password = "xyz", db = "Services") if (mongo.is.connected(mongo)){

  • print(mongo.count(mongo, "Services-Metrics-Val.Firebrand"))
  • } [1] 11441

Can you tell me what I am missing? Is it something to do with new version of Mongodb?

Thanks a lot and and let me know if you need more information.

Ankit