简体   繁体   English

连接MongoDB Atlas

[英]Connecting to MongoDB Atlas

I am trying to connect to my cluster on MongoDB Atlas using MongoDB compass using the string provided by Atlas mongodb+srv://<user-id>:<password>@<url> .我正在尝试使用 MongoDB 指南针使用 Atlas 提供的字符串连接到 MongoDB Atlas 上的集群mongodb+srv://<user-id>:<password>@<url> Not able to connect.无法连接。 Connection just get closed.连接刚刚关闭。

Also tried from command line the mongostat command with the similar string provided by Atlas.还从命令行尝试使用 Atlas 提供的类似字符串的 mongostat 命令。 There I am getting the error given below.我收到下面给出的错误。

2021-05-25T10:30:44.987+0530 could not connect to server: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: :27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection(): connection(:27017[-45]) incomplete read of message header: EOF }, ] }. 2021-05-25T10:30:44.987+0530 无法连接到服务器:服务器选择错误:服务器选择超时,当前拓扑:{ 类型:单一,服务器:[{ 地址::27017,类型:未知,State:已连接,平均 RTT:0,最后一个错误:connection():connection(:27017[-45]) 未完成消息 header: EOF }, ] } 的读取。

Please help.请帮忙。

You have to to make sure the mongod daemon, is running the background process, before trying to connect to MongoDB ATlas using MongoDB Compass , else data requests, data access and background management process would not work.在尝试使用MongoDB Compass连接到MongoDB ATlas之前,您必须确保mongod守护进程正在运行后台进程,否则数据请求、数据访问和后台管理进程将无法正常工作。 about mongod To get MongoDB Compass , connected to your MongoDB Atlas关于 mongod获取MongoDB 指南针,连接到您的MongoDB 地图集

  1. You could cd change directory to the installation path of MongoDB , and manually run mongod.exe command before connecting as seen below:您可以cd更改目录到MongoDB的安装路径,并在连接之前手动运行mongod.exe命令,如下所示: 将目录更改为mongodb安装路径

  2. And then run, the mongod.exe to start the daemon process as seen below然后运行, mongod.exe启动守护进程,如下所示mongod守护进程运行

NOTE Or you could set your mongod process in your system environment variables , so it automatically starts when, your pc boots up: as seen as this also:注意或者你可以在你的系统环境变量中设置你的mongod进程,所以它会在你的电脑启动时自动启动:也可以看到: 在环境变量中设置 mongod

  1. Then you can connect to your MongoDB Atlas Cluster using the connection string provided as seen below:然后,您可以使用提供的连接字符串连接到MongoDB Atlas Cluster ,如下所示: 使用连接字符串连接到 mongodb atlas

  2. Below is the list of databases and collection in my atlas cluster:以下是我的 atlas 集群中的数据库和集合列表: 我的共享 Atlas 集群中的数据库

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM