[英]What should I enter to the connection string to connect my NodeJS application to a MongoDB server?
I am trying to connect to a MongoDB to a nodejs.我正在尝试将 MongoDB 连接到 nodejs。 I have the MongoDB running and I have an ENV file with a connection string variable.我有 MongoDB 正在运行,并且我有一个带有连接字符串变量的 ENV 文件。 I just don't know what to set the string to connect the data I created to the data.我只是不知道要设置什么字符串来将我创建的数据连接到数据。
Terminal:终端:
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()
---
>
.env .env
CONNECTION_STRING="mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb"
Remove gssapiServiceName
& compressors
from connection string and add DB name at the end like the example below从连接字符串中删除gssapiServiceName
和compressors
,并在末尾添加数据库名称,如下例所示
CONNECTION_STRING="mongodb://127.0.0.1:27017/db_name"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.