database 访问 Meteor 生产数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11801278/
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
Accessing Meteor production database
提问by genkiro
To check out what's in the (production) database for blah.meteor.comI thought we would just do:
要查看(生产)数据库中的内容,blah.meteor.com我认为我们会这样做:
meteor mongo --url http://blah.meteor.com/
But instead I get a URI:
但相反,我得到了一个 URI:
mongodb://client:984dae4c-04fb-c8bb-68f6-ed83602435cc@skybreak.member1.mongolayer.com:27017/blah_meteor_com
How would I use this URI to access the db?
我将如何使用这个 URI 来访问数据库?
回答by nsmeta
You should use meteor mongo http://blah.meteor.com; or even shorter meteor mongo blah.meteor.com.
你应该使用meteor mongo http://blah.meteor.com; 甚至更短meteor mongo blah.meteor.com。
For documentation you can run meteor help mongo. Extract from running the help command above:
对于文档,您可以运行meteor help mongo. 从运行上面的帮助命令中提取:
Instead of opening a shell, specifying --url (-U) will return a URL suitable for an external program to connect to the database. For remote databases on deployed applications, the URL is valid for one minute.
指定 --url (-U) 将返回一个适合外部程序连接到数据库的 URL,而不是打开 shell。对于已部署应用程序上的远程数据库,该 URL 的有效期为一分钟。
So what it's saying is, the url provided by running the command with the --urloption is for connecting to the database by some external application, i.e. other than meteor.
所以它的意思是,通过运行带有--url选项的命令提供的 url用于通过某些外部应用程序连接到数据库,即meteor.
UPDATE:
更新:
When you connect to MongoDB, you should get a greeting message similar to this:
当您连接到 MongoDB 时,您应该会收到类似于以下内容的问候消息:
MongoDB shell version: 2.0.2
connecting to: skybreak.member1.mongolayer.com:27017/userdb_meteor_com
Enter the following command: use userdb_meteor_com(where userdb_meteor_comis taken from the URL in the greeting message above).
输入以下命令:(use userdb_meteor_com其中userdb_meteor_com取自上述问候消息中的 URL)。
To see your collections (usually they refer to collections created in your Meteor app): show collections. You should get something like this:
要查看您的收藏(通常是指在您的 Meteor 应用程序中创建的收藏):show collections. 你应该得到这样的东西:
system.indexes
system.users
users
Now you can run usual commands, e.g.: db.users.find({});.
现在您可以运行常用命令,例如:db.users.find({});.
回答by JobJob
Simplified version of nsmeta's informative answer for the speed scanners out there:
nsmeta 为速度扫描仪提供的信息答案的简化版本:
$ meteor mongo blah.meteor.com
connecting to: ...
> show collections
stuff
> db.stuff.find()
{"_id" : "abcdedghiasdjlahf", stuff: "yeah!" }
回答by Ser
UPDATE 2016:
2016 年更新:
The meteor mongocommand is not working anymore because the blah.meteor.com database is version 3.0 while the meteor mongocommand is still at version 2.6.7. (on the last version of Meteor, v1.2.1).
该meteor mongo命令不再起作用,因为 blah.meteor.com 数据库是 3.0 版,而该meteor mongo命令仍是 2.6.7 版。(在 Meteor 的最新版本,v1.2.1)。
Instead, install the mongo cli and run this command :
相反,安装 mongo cli 并运行以下命令:
mongo `meteor mongo --url blah.meteor.com | sed 's/mongodb:\/\//-u /' | sed 's/:/ -p /' | sed 's/@/ /'`
mongo `meteor mongo --url blah.meteor.com | sed 's/mongodb:\/\//-u /' | sed 's/:/ -p /' | sed 's/@/ /'`
More details: Accessing meteor production database in 2016
更多详情:2016年访问流星生产数据库

