【问题标题】:NEST - Unable to connect to the database. Retrying (2)NEST - 无法连接到数据库。重试 (2)
【发布时间】:2022-01-03 11:55:11
【问题描述】:

我正在尝试通过 nest 模块与 mongodb 进行连接。但是当我传递用户和密码参数时,连接没有建立。但是如果没有用户名和密码参数,就会建立连接。

MongooseModule.forRoot('mongodb://username:pass!@127.0.0.1:22587/test')
ERROR [MongooseModule] Unable to connect to the database.


MongooseModule.forRoot('mongodb://127.0.0.1:22587/test')
LOG [InstanceLoader] MongooseModule dependencies initialized

【问题讨论】:

    标签: javascript mongodb mongoose nestjs


    【解决方案1】:

    问题不在于我将 d 参数传递到了错误的位置。

    MongooseModule.forRoot('mongodb://127.0.0.1:22587',
        {
            user: dbUser
            pass: dbPass
        }
    )
    

    【讨论】:

    • 欢迎来到 Stack Overflow _ 我已经标记了您的答案,因为它只是对您已经评论过的上一个答案的回复。 SO 帖子的答案部分专为尝试回答帖子问题而保留。如果您认为应将此答案的内容添加到您的问题中,那么您应该将其添加到那里。请访问 SO 帮助中心,特别是本指南以获取更多详细信息 >>> stackoverflow.com/help/how-to-answer
    猜你喜欢
    • 1970-01-01
    • 2020-10-20
    • 2020-04-15
    • 2016-07-30
    • 2018-10-22
    • 2016-11-20
    • 2020-11-24
    • 2011-06-16
    相关资源
    最近更新 更多