如何将 mongodb 客户端连接到本地 Meteor MongoDB

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22020580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 13:36:38  来源:igfitidea点击:

How to connect mongodb clients to local Meteor MongoDB

mongodbmeteor

提问by user3330705

How can I connect Robomongo (or any other mongodb client) to the mongodb instance that is created by my local Meteor application?

如何将 Robomongo(或任何其他 mongodb 客户端)连接到由本地 Meteor 应用程序创建的 mongodb 实例?

回答by Serkan Durusoy

Ensure Meteor is running on localhost. Open a terminal window and run meteorcommand. It will start running on localhost:3000 if you have not changed to port.

确保 Meteor 在本地主机上运行。打开终端窗口并运行meteor命令。如果您没有更改为端口,它将开始在 localhost:3000 上运行。

While it is running, open a separate terminal window and run meteor mongocommand. This will open up a MongoDB shell and tell you what port it is connecting to This is normally 3001 as of version 0.7.1.1 or 3002 if earlier. It will say something like 127.0.0.1:3001/meteor

在它运行时,打开一个单独的终端窗口并运行meteor mongo命令。这将打开一个 MongoDB shell 并告诉您它连接到哪个端口。从版本 0.7.1.1 或 3002(如果更早)开始,这通常是 3001。它会说类似的话127.0.0.1:3001/meteor

Go to Robomongo (or your favorite mongodb client software) and create a new connection, making sure to change the connection address to localhost and the given the port number. No need to additionally define /meteor if your client does not insist on a default database.

转到 Robomongo(或您最喜欢的 mongodb 客户端软件)并创建一个新连接,确保将连接地址更改为 localhost 和给定的端口号。如果您的客户不坚持使用默认数据库,则无需额外定义 /meteor。

Also as pointed out in https://stackoverflow.com/a/22023284/1064151some drivers may need specific line endings, delimeters or other character flow. For example, ObjCMongoDBa C based driver wants the url to be 127.0.0.1:3001/with that extra /at the end, or it won't work. So make sure you check the documentation for your driver/client.

同样如https://stackoverflow.com/a/22023284/1064151 中所指出的,某些驱动程序可能需要特定的行尾、分隔符或其他字符流。例如,ObjCMongoDB是一个基于 C 的驱动程序,它希望 url在末尾127.0.0.1:3001/带有额外/的内容,否则它将无法工作。因此,请确保检查驱动程序/客户端的文档。

回答by imal hasaranga perera

Easiest way to get the current configuration details is to use the following command

获取当前配置详细信息的最简单方法是使用以下命令

meteor mongo -U

This will give you the connection string

这将为您提供连接字符串

回答by J4cK

From terminal run following command

从终端运行以下命令

meteor mongo -U

That will show you the local host IP address and in which port you application is running. Now run the Robomongo and configure as following two field as you got by running the previous command

这将显示本地主机 IP 地址以及应用程序运行的端口。现在运行 Robomongo 并按照您通过运行上一个命令获得的两个字段进行配置

enter image description here

enter image description here

回答by Nate

I'm using ObjCMongoDB, a C based mongoDB driver. With the new update instead of using the previous 127.0.0.1:3002to connect to my localhost running meteor's mongodb, I now need to use 127.0.0.1:3001/with the collection name still being meteor.collection. The important change is the port from :3002to :3001/. Remember the /, it is critical for the connection.

我正在使用ObjCMongoDB,一个基于 C 的 mongoDB 驱动程序。使用新的更新而不是使用以前127.0.0.1:3002的连接到我的本地主机运行流星的 mongodb,我现在需要使用127.0.0.1:3001/集合名称仍然是meteor.collection. 重要的变化是端口从:3002:3001/。请记住/,它对于连接至关重要。

回答by Hymanal

This worked for me,Before connecting make sure meteor is running. I am using Robomongo to connect. Create new connection and add Address as : localhost; port as: 3001

这对我有用,在连接之前确保流星正在运行。我正在使用 Robomongo 进行连接。创建新连接并将地址添加为:localhost;端口为:3001

回答by Sasikanth

I'm too using Robomongo and before the latest update V0.7.1,i used port 3002 to connect,as @Serkan Durusoy suggest's for the latest update it is working for 3001 port

我也使用 Robomongo,在最新更新 V0.7.1 之前,我使用端口 3002 进行连接,正如@Serkan Durusoy 建议的最新更新,它适用于 3001 端口

回答by Brunno Vodola Martins

@imal365 answer is perfect. Just to add my insight on it:

@imal365 答案是完美的。只是补充一下我的见解:

I realized that the default Meteor Mongo port number is the port number of the application with 1 added to it (as of version 0.7.1.1). In my case, I was running Meteor on port 1337with the command meteor --port 1337and my Meteor Mongo port was 1338.

我意识到默认的 Meteor Mongo 端口号是应用程序的端口号加上 1(从 0.7.1.1 版本开始)。就我而言,我1337使用命令在端口上运行 Meteor,meteor --port 1337而我的 Meteor Mongo 端口是1338.

回答by Parth mehta

Use SSH tunneling by the following command :

通过以下命令使用 SSH 隧道:

ssh -L 3001:localhost:3001 user-name@host

It forwards connections from your local port 3001 to localhost:3001 on your server. Now we can simply connect to our database.

它将连接从本地端口 3001 转发到服务器上的 localhost:3001。现在我们可以简单地连接到我们的数据库。

Create a Robomongo connection on your localhostand hit Test(Out of two checks, Authentication may fail) :

本地主机上创建 Robomongo 连接并点击测试(在两次检查中,身份验证可能会失败):

enter image description here

enter image description here