微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我应该在连接字符串中输入什么来将我的 NodeJS 应用程序连接到 MongoDB 服务器?

如何解决我应该在连接字符串中输入什么来将我的 NodeJS 应用程序连接到 MongoDB 服务器?

我正在尝试将 MongoDB 连接到 nodejs。我正在运行 MongoDB,并且我有一个带有连接字符串变量的 ENV 文件。我只是不知道该设置什么字符串以将我创建的数据连接到数据。

终端:

loop_thru_arguement_list_to_create_end_string

.env

connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("a301b4da-919f-4e58-a524-b6851fac71c7") }
MongoDB server version: 4.4.4
---
The server generated these startup warnings when booting: 
        2021-04-15T18:15:59.961-04:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
        2021-04-15T18:15:59.961-04:00: Soft rlimits too low
        2021-04-15T18:15:59.961-04:00:         currentValue: 256
        2021-04-15T18:15:59.961-04:00:         recommendedMinimum: 64000
---
---
        Enable MongoDB's free cloud-based monitoring service,which will then receive and display
        metrics about your deployment (disk utilization,cpu,operation statistics,etc).

        The monitoring data will be available on a MongoDB website with a unique URL accessible to you
        and anyone you share the URL with. MongoDB may use this information to make product
        improvements and to suggest MongoDB products and deployment options to you.

        To enable free monitoring,run the following command: db.enableFreeMonitoring()
        To permanently disable this reminder,run the following command: db.disableFreeMonitoring()
---
> 

解决方法

从连接字符串中删除 gssapiServiceName & compressors 并在末尾添加数据库名称,如下例所示

CONNECTION_STRING="mongodb://127.0.0.1:27017/db_name"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。