我正在尝试通过mongo给我的连接字符串连接到我的mongoDB服务器:
"mongodb+srv://david:password@cluster0-re3gq.mongodb.net/test?retryWrites=true"
在我的代码中,我像这样通过mongoose调用连接(显然输入了我的密码):
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));
当我运行代码时,我得到了以下错误
"MongoError:错误的身份验证失败。“
你知道这意味着什么吗?
发布于 2019-04-19 02:19:57
我想你把mongodb帐号密码和用户密码搞混了。您应该使用用户密码,而不是帐户密码。这就是我的案子的原因。
发布于 2019-04-18 00:39:27
我遇到了同样的问题,在我的例子中,答案很简单,只需删除<password>
周围的尖括号“<”和">“即可。我一直在尝试:my_login_id:<my_password>
,当它应该是my_login_id:my_password
的时候。
发布于 2019-10-22 14:21:17
这是因为输入的密码是wrong.Because,您输入的是登录密码,而不是集群密码。
Solution ===> step 1.在mongodb图集页面左侧导航中单击数据库访问。
步骤2.选择您的用户名,然后单击以从右侧进行编辑。
步骤3.单击以更改密码。
步骤4.单击更新用户。
在更改密码时,密码只按字母顺序排列,因为特殊字符需要编码。
这就是您现在可以连接的全部内容。
祝你编码愉快。
https://stackoverflow.com/questions/55695565
复制相似问题