44

To check out what's in the (production) database for blah.meteor.com I thought we would just do:

meteor mongo --url http://blah.meteor.com/

But instead I get a 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?

Community
  • 1
  • 1
genkiro
  • 571
  • 1
  • 6
  • 12

3 Answers3

74

You should use meteor mongo http://blah.meteor.com; or even shorter meteor mongo blah.meteor.com.

For documentation you can run meteor help mongo. Extract from running the help command above:

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.

So what it's saying is, the url provided by running the command with the --url option is for connecting to the database by some external application, i.e. other than meteor.

UPDATE:

When you connect to MongoDB, you should get a greeting message similar to this:

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_com is taken from the URL in the greeting message above).

To see your collections (usually they refer to collections created in your Meteor app): show collections. You should get something like this:

system.indexes
system.users
users

Now you can run usual commands, e.g.: db.users.find({});.

nsmeta
  • 1,898
  • 1
  • 17
  • 14
  • Thank you. Now I am able to connect successfully, but every time I do a query, it is saying that I am unauthorized. I don't remember entering any password. Does meteor setup username & password by default? – genkiro Aug 03 '12 at 20:58
  • http://meteor.com/blog/2011/12/09/production-database-access-password-protection and here's the original blog post – Darren Shewry Mar 17 '13 at 10:20
  • or even shorter, you can use: meteor mongo blah – kahmali Oct 31 '14 at 20:54
  • I get "not authorized for insert on meteor.db.myCollection" when trying to insert using this created URL.. What user/pass do I need for writes? I am trying to insert from the shell. – Dylan Reich Dec 22 '14 at 09:07
  • The credentials (user/pwd) you get from `meteor mongo -U ` expire after about 60min. Is there any way to get or create permanent credentials? – kynan Jun 13 '15 at 13:26
14

Simplified version of nsmeta's informative answer for the speed scanners out there:

$ meteor mongo blah.meteor.com
connecting to: ...
> show collections
    stuff
> db.stuff.find()
    {"_id" : "abcdedghiasdjlahf", stuff: "yeah!" }
JobJob
  • 3,822
  • 3
  • 33
  • 34
3

UPDATE 2016:

The meteor mongo command is not working anymore because the blah.meteor.com database is version 3.0 while the meteor mongo command is still at version 2.6.7. (on the last version of Meteor, v1.2.1).

Instead, install the mongo cli and run this command :

mongo `meteor mongo --url blah.meteor.com | sed 's/mongodb:\/\//-u /' | sed 's/:/ -p /' | sed 's/@/ /'`

More details: Accessing meteor production database in 2016

Community
  • 1
  • 1
Ser
  • 2,661
  • 23
  • 28