错误消息:MongoError:错误的身份验证身份验证失败通过URI字符串 [英] Error Message: MongoError: bad auth Authentication failed through URI string
问题描述
对于MongoDB和Node.js来说是全新的.我正在尝试通过mongo给我的连接字符串连接到我的mongoDB服务器:
Very new to MongoDB and Node.js. I'm trying to connect to my mongoDB server via the connection string given to me by mongo:
"mongodb + srv://david:password@cluster0-re3gq.mongodb.net/test?retryWrites = true"
"mongodb+srv://david:password@cluster0-re3gq.mongodb.net/test?retryWrites=true"
在我的代码中,我像这样通过猫鼬调用连接(显然输入了密码):
In my code I am calling the connection through mongoose like this (obviously putting in my password):
const mongoose = require('mongoose');
const db = 'mongodb+srv://david:<password>@cluster0-re3gq.mongodb.net/test?retryWrites=true'
mongoose
.connect(db, {
useNewUrlParser: true,
useCreateIndex: true
})
.then(() => console.log('MongoDB connected...'))
.catch(err => console.log(err));
运行代码时,出现以下错误
When I run the code I am getting the following error
"MongoError:错误的身份验证失败."
"MongoError: bad auth Authentication failed."
关于这意味着什么的任何想法?谢谢!
Any ideas of what that could mean? Thanks!
推荐答案
我认为您对mongodb帐户密码和用户密码感到困惑. 您应该使用用户密码,而不是帐户密码. 那就是我的理由.
I think you're confused with the mongodb account password and user password. You should use user password, not account password. That was the reason of my case.
这篇关于错误消息:MongoError:错误的身份验证身份验证失败通过URI字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!