MongoDB 尝试连接到我的本地数据库时,Compass 强制我输入副本集名称。我可以避免这种情况吗?

MongoDB Compass forces me to enter Replica Set Name when trying to connect to my local DB. Can I avoid this?

编辑:

不确定我做了哪些不同的事情(同样,这是我处理所有这些的第一步),但现在我没有收到之前收到的错误消息。相反,它只是尝试建立连接,我得到

Server selection timed out after 30000 ms

一段时间后。

原创:

我刚开始使用 MongoDB - 目前正在在线学习后端课程。

Compass 似乎最近更改了他们的界面以添加新连接,也许还有一些业务逻辑,因为我找到的所有指南都使用以前的指南。

具体来说,在添加新连接时,在我阅读的指南中,它们将 Replica Set Name 留空。当我尝试这样做时,我收到一条错误消息 Incomplete key value pair for option

我试过只称它为 localhost 和 "works",但我没有看到我的任何数据库。 如果我与 Robo 3t 连接,我可以看到它们。

阻止我处理 DB 的 Replica Set Name 是错误的吗?还是我做错了什么?

我尝试连接时的设置是:

Hostname : `localhost`
port : 27017
SRV record : I leave it off
Authentication : None
Replica Set Name : localhost
Read preferences : Primary
SSl : none
SSL tunnel : None

Compass 似乎需要指定副本集名称,这是基于我在指定一个恰好是辅助主机时收到的以下消息:

An error occurred while loading navigation: 'not master and slaveOk=false': It is recommended to change your read preference in the connection dialog to Primary Preferred or Secondary Preferred or provide a replica set name for a full topology connection.

"Server selection timed out" 可以表示不同的意思:

  • 没有数据库运行。
  • 数据库是运行但是你输入了错误的端口号。
  • Compass 试图执行需要特定服务器类型(例如主要或辅助)的特定操作。数据库是 运行 并且有一个服务器正在侦听您指定的端口,但它的类型错误。

仅凭错误消息很难判断是哪种情况。

作为副本集成员(主要),我在一台机器上进行开发时遇到了同样的问题。我这样做是因为我必须使用 spring-data-mongodb@Transactional。为我解决的是登录 mongo shell 并发出: rs.initiate();