本文介绍了“Meteor mongo"问题连接到单独的 Mongo 实例时的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在本地运行party"示例时,如果我首先指定我的 MONGO_URL 以使用已经存在的 mongo 实例 meteor mongo 报告meteor 没有运行,即使它是,即使它连接到一个单独的 mongo 实例就好了.

When running the "parties" example locally, if I first specify my MONGO_URL to use an already existing mongo instance meteor mongo reports that meteor isn't running, even though it is and even though it is connecting just fine to a separate mongo instance.

如果您在没有指定单独 MONGO_URL 的情况下运行meteor 应用程序,则没有问题meteor mongo 按预期工作

If you run the meteor app without specifying a separate MONGO_URL, no problems meteor mongo works as expected

现在我也尝试在运行 meteor mongo 之前设置 MONGO_URL 无济于事.我还没有尝试部署该应用程序以查看会发生什么.

Now I have also tried setting the MONGO_URL before running meteor mongo to no avail. I haven't tried deploying the app to see what would happen.

另一个尝试进行故障排除是在运行应用程序后,我尝试使用meteor mongo 与--url localhost:27017 标志进行连接,它要求输入密码:.这应该给我一个连接到数据库实例的 URL,并且密码请求也不是 mongo,因为

The one other attempt to troubleshoot is after running the app, I try to connect using meteor mongo with the --url localhost:27017 flag it asks for a Password:. This is supposed to give me a URL to connect to the database instance, and the request for a Password isn't mongo either, since

a) 我没有在本地实例上启用身份验证

a) I don't have authentication enabled on my local instance

b) 即使本地实例没有运行并且您运行 meteor mongo 它仍然要求输入密码.

b) Even if the local instance isn't running and you run meteor mongo it still asks for a password.

在meteor 文档中,它在meteor mongo 下注明:

In the meteor documentation it notes under meteor mongo:

现在,您必须已经使用meteor run 在本地运行您的应用程序.>将来这会更容易.

这是他们的意思吗?

显然,我是否拥有从meteor 到本地实例的shell 访问并不重要,因为我总是可以通过键入mongo 来获得shell 访问,但我关心的是部署,我是否应该想要shell 访问,这可能是个问题.

Obviously, it is isn't crucial that I have shell access from meteor to my local instance since I can always get shell access by just typing mongo, but my concern has to do with deployment, and should I want shell access then, this might be a problem.

推荐答案

Meteor mongo 是为了在开发中运行时连接到 mongo 数据库meteor run,即使用 meteor run 运行,没有 MONGO_URL 或在meteor.com 上处于部署模式

Meteor mongo is meant to connect to the mongo database meteor runs when it runs in development, i.e that is run with meteor run, without a MONGO_URL or in deployment mode on meteor.com

这意味着它无法访问其他 mongodb,例如,如果您指定 MONGO_URL.流星 mongo 实际上会在您的项目的 .meteor 目录中查找运行的 mongodb 的运行进程 ID.

This means it can't access other mongodbs, for instance if you specify MONGO_URL. meteor mongo will actually look for the running process id of the mongodb running in the .meteor directory of your project.

meteor mongo --url localhost:27017 要求输入密码的原因是它试图连接到meteor.com 托管(如果你通过meteor deploy 部署了你的应用程序),所以如果你部署了你的应用程序到 test.meteor.com 你可以通过 meteor mongo test.meteor.com 访问它的 mongodb uri.如果设置了密码,它会要求输入该密码.

The reason meteor mongo --url localhost:27017 asks for a password is its attempting to connect to meteor.com hosting (if you deployed your app via meteor deploy), so if you deployed your app to test.meteor.com you could access its mongodb uri via meteor mongo test.meteor.com. If a password is set it will ask for that password.

要访问您的本地 mongodb 集合,您必须查看 mongodb 实例的 /bin 目录或使用 mongo --dbpath xxx 其中 xxx 是您的数据库所在的位置已安装.(或者正如你提到的使用 mongo)

To access your local mongodb collection you would have to look at the /bin directory of your mongodb instance or use mongo --dbpath xxx where xxx is where your database is installed. (Or as you mentioned to use mongo)

这篇关于“Meteor mongo"问题连接到单独的 Mongo 实例时的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 18:42