简体   繁体   English

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

[英]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从连接字符串中删除gssapiServiceNamecompressors ,并在末尾添加数据库名称,如下例所示

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NodeJS MongoDB连接字符串问题 - NodeJS MongoDB Connection string problems Angularjs:我想编辑提交给后端nodejs> Mongodb的数据。 我应该遵循的最佳设计是什么? - Angularjs: I want to edit data submitted to my backend nodejs > Mongodb. What is the best design that I should follow? 我在nodejs / mongodb上的更新功能在做什么? - What am I doing wrong on my update function on nodejs/mongodb? 我应该知道什么让我的nodejs服务器公开而不依赖 - Whats i should know to make my nodejs server public with no dependencies 如何让我的 NodeJS 应用程序在服务器上运行? - How can I get my NodeJS application working on a server? 如何以及在何处正确连接和结束 nodejs 中的 mongoDB 连接 - How and where properly connect and end mongoDB connection in nodejs 我无法通过Mongoose在NodeJS上建立MongoDB和我的网站之间的连接 - I can't establish a connection between MongoDB and my website on NodeJS via Mongoose 我应该使用哪些工具为我的Web应用程序创建教程? - What tools should I use to create a tutorial for my web application? 我应该如何固定页脚在ionic 3应用程序中的位置? - What should i do to fix the position of footer in my ionic 3 application? 通过Node.js Express应用程序保持mongodb(2.0)连接 - Persisting mongodb (2.0) connection through nodejs Express Application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM