I'm trying to connect my server to my MongoDB database in production,
But When I try to do that :
mongoose.connect("mongodb://user:randompassword@ds011452.mlab.com:11452/dbname?authSource=dbWithUserCredentials");
I get a
connection error: { [MongoError: auth failed] name: 'MongoError', ok: 0, errmsg: 'auth failed', code: 18 }
note : my dbname is the same as the username...
Any IDeas ?
I've find my answer :
I've upgraded mongoDB
to the 3.0 version
,
and after that I've upgraded mongoose
to the > 4.3.0 version
http://mongoosejs.com/docs/compatibility.html
and It works !
edit :
after update mongoDB to 3.0 (I used brew
)
package.json
->
"dependencies": {
"mongoose": "~4.3.0",
...
then npm install
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.