Mongoose Authentication Using SCRAM-SHA-1

I recently upgraded from MongoDB 2.6 to 3.0.4, and also upgraded from Mongoose to 4.0.0.

Now when I try to connect to mongo using mongoose:

mongoose.connect('mongodb://user: password@host :port/dbname') 

In mongo logs I get this message

SCRAM-SHA-1 authentication error for a user on dbname from client xxx.xxx.xxx.xxx

I checked in mongodb, the user exists in admin. The command I used is db.system.users.findOne({user:'user'})

The information returned by this statement contains SCRAM-SHA-1 information.

My question is how to specify SCRAM related information in the mongoose when establishing a connection. I read many articles, but did not understand how to do this.

+1
mongoose
source share
3 answers

Found a solution, I did not pass the name authDatabase, so the connection failed. I used to use this

 mongoose.connect('mongodb://user: password@host :port/dbname') 

Now i used this

 mongoose.connect('mongodb://user: password@host :port/dbname?authSource=dbWithUserCredentials') 

Found this solution on the topic Discussion of Mongoose itself

+3
source share

I had a similar problem. This was fixed after updating the mongoose to version 4.1.1.

+6
source share

Mongoose version 4.0.3 changed and it works.

0
source share

All Articles