Image上找到用户名

Image上找到用户名

本文介绍了MongoDB Auth未能在Bitnami MEAN Stack Image上找到用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在Amazon EC2实例上运行Web应用程序(MEAN),但遇到以下问题.有人可以帮我吗?

Trying to run a web app (MEAN) on Amazon EC2 Instance but am encountering the following problem. Can anyone help me with this?

node app.js The Server has started on 9091
/opt/bitnami/apps/YelpCamp/node_modules/mongodb-core/lib/auth/scram.js:128
    username = username.replace('=', "=3D").replace(',', '=2C');
                        ^

TypeError: Cannot read property 'replace' of undefined
    at executeScram (/opt/bitnami/apps/SomeApp/node_modules/mongodb-core/lib/auth/scram.js:128:24)
    at /opt/bitnami/apps/SomeApp/node_modules/mongodb-core/lib/auth/scram.js:277:7
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)

推荐答案

猫鼬可以通过两种方式进行身份验证:

Mongoose can do auth in 2 ways:

1,连接字符串:mongoose.connect('mongodb://username:password@host:port(usually 27017)/db')其中username和password是该特定数据库的相应用户名和密码,host将是托管数据库的主机(因此localhost或某些域/IP),port是mongo侦听的端口,db是该数据库的名称.您要连接的数据库

1, Connection string:mongoose.connect('mongodb://username:password@host:port(usually 27017)/db')Where username and password are the respective username and password for that specific db, host would be the host where your db is hosted (so localhost or some domain/IP), port is the port mongo listens on, and db is the name of the db you want to connect to

2,使用选项.从文档中:var options = { useMongoClinet: true, auth: {authdb: 'admin'}, user: 'myUsername', pass: 'myPassword',}mongoose.connect(uri, options);

2, Using options. From the docs:var options = { useMongoClinet: true, auth: {authdb: 'admin'}, user: 'myUsername', pass: 'myPassword',}mongoose.connect(uri, options);

在第一种方法中我也遇到了用户名未定义"错误,但是在第二种方法中我成功了.

I also faced the 'username undefined' error in the first approach, but I succeeded in the second approach.

[参考] https://github.com/Automattic/mongoose/issues/4891

这篇关于MongoDB Auth未能在Bitnami MEAN Stack Image上找到用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 18:43