MongoError:身份验证失败的猫鼬连接st [英] MongoError: auth failed mongoose connection sting
本文介绍了MongoError:身份验证失败的猫鼬连接st的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以通过终端连接到DB,但是使用猫鼬和gulp会出现此错误. 猫鼬/node_modules/mongodb/lib/mongodb/connection/base.js:246 MongoError:身份验证失败
I can connect to the DB through terminal, but getting this error using mongoose and gulp. mongoose/node_modules/mongodb/lib/mongodb/connection/base.js:246 MongoError: auth failed
我的连接字符串是:
mongodb://usr:psw@localhost:27017/dbname
有什么想法吗?
推荐答案
我在 https://bitnami上安装了MEAN. Windows 7的com/stack/mean 安装时,我的密码是123456
I installed MEAN at https://bitnami.com/stack/mean for windows 7 When install I make password is 123456
语法使与猫鼬连接到mongodb
Syntax make connect to mongodb with mongoose
mongoose.connect("mongodb://[usr]:[pwd]@localhost:[port]/[db]",{auth:{authdb:"admin"}});
如果没有
{auth:{authdb:"admin"}}
您将收到错误消息"MongoError:身份验证失败"
You will get error message "MongoError: auth failed"
示例:mongo-test/app.js
Example: mongo-test/app.js
var mongoose = require('mongoose');
mongoose.connect('mongodb://root:123456@localhost/test',{auth:{authdb:"admin"}});
mongoose.set('debug', true); // turn on debug
这篇关于MongoError:身份验证失败的猫鼬连接st的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文