I'm new to both Meteor.js and MongoDB and after installing Meteor in the official way described I wonder how to connect to my MongoDB.
MongoDB was installed by Meteor during the installation and everything works fine but now I would like to have a look into it with another tool (like RazorSQL) to see what's in there.
But the standard connection parameters (localhost:27017) doesn't work, what can I do? Login? Password?
Update: February 2014 - Meteor 0.7.1 - The meteor port has been shifted to 3001 instead of 3002. So instead of adding two to the port meteor runs on, you add 1 instead.
MongoDB's database is installed in the meteor package containing your files in a hidden folder called .meteor. To access it from a remote tool simply add 2 to whatever your web server port is while meteor is running. It will be stored in the meteor database
e.g
http://localhost:3000 would have its mongodb server running at mongodb://localhost:3002/meteor there is no username/password on this instance if you ran it with meteor or meteor run
To get the Meteor Mongo url and port, first run your Meteor app using meteor run then run meteor mongo in a different terminal tab. You should see an output like this
[meteor-app] meteor mongo
MongoDB shell version: 2.6.7
connecting to: 127.0.0.1:3001/meteor
this means that your Meteor Mongo is running at 127.0.0.1:3001.
If you are running your Meteor app with meteor run then you neither need username/password nor authentication configuration just make sure that you set your default database name as meteor
Related
I have a dump folder which was created few year ago using mongodump, and want to use this info with a newly created metor app which is the same as the old meteor app after few packages updates and runs without errors.
I installed the mongodb server on this windows 10, the cmd mongo prints
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
MongoDB server version: 4.2.7
what is the "best" way to use the info with the meteor app.
Can some one please give the overview of how all this things work together and then how to use the old info "including the command mongorestore" with the newly created metoer app?
It has been few years so will need polish my thinking on meteor and mongodb again.
My understanding is mongorestore the backup, then run the mongodb server in a separate cmd window, issue a cmd to connect to the restored database, and somehow tell meteor to use this server. Ok I give up.
Thanks
Meteor comes with a bundled MongoDB in development mode, where the mongodb always runs on the app's port + 1 (app: 3000 = mongo: 3001).
You can simply start your Meteor app and when running open a new console and cd into your project folder, then enter:
mongorestore -h localhost:3001 --db meteor /path/to/dump/
I've been working on a project with some friends using MongoDB and Meteor. It was working fine until we deployed it, we noticed the Mongo DB was not connecting to the Meteor app.
We are using:
Azure's Virtual Machine server
Meteor for development
Mongo for our database (Hosted in Azure's Document DB, different location from the Meteor's Azure VM)
Meteor up (mup) for deployment
We did notice that when we run the project locally with meteor, we need to specify the MONGO_URL on the same command (MONGO_URL="MongoDB connection string" meteor) if not, it doesn't connect to the db. This may be happening on the website, although we have specified the mongo url in the mup as follows:
env: {
ROOT_URL: 'IP',
MONGO_URL: '<URL>'
},
We have checked everything and not sure how to proceed, any feedback would help.
EDIT: Specify server locations
I have started looking at Meteor and tried out some examples, but I'm puzzled by something: I have installed Meteor and not MongoDB on my machine, but Meteor seems to create its own instance of MongoDB.
How does this work?
Am I able to develop a separate application that can also perform CRUD operations on this database that Meteor is spinning up?
Meteor is shipped with a MongoDB installation
I think you can. The meteor mongo command gives the MongoDB URL to the database Meteor spins up.
meteor command will start its own instance of MongoDB.
You can then use meteor mongo to connect to the MongoDB database, which is usually running on the application's port+1, for example, app:3000 -> mongodb#:3001. So you could use any MongoDB tool to connect (for example, robomongo).
$ meteor mongo
MongoDB shell version: 2.4.9
connecting to: 127.0.0.1:3001/meteor
I am using PhpStorm editor with mongoDB plugin, I was wondering what should be the mongodb server url,so I could monitor my mongoDB's activities directly from PhpStorm
It depends if you set MONGO_URL. If you run meteor locally with out setting MONGO_URL try
mongo localhost:3001/meteor
If you have deployed your app to meteor.com try
meteor mongo yourapp.meteor.com --url
This will return the MONGO_URLso that you can monitor/backup/restore your DB. Eg
mongodb://client-lots-of-numers#production-db-a1.meteor.io:27017/yourapp_meteor_com
When running MongoDB using the meteor command line you can access the database at localhost:3001. The database name is meteor and there is no need for credentials.
I have Windows PC running two ubuntu virtual machines. One has Meteor installed (app server), to other has Mongo installed (the purpose of this is to use Mongo away from the app server so that it will scale later on). Problem is that I cannot connect to Mongo instance from Meteor!
I can connect to the mongo instance from the the app server when using the line below on the command line and can retrieve data from the collection:
mongo 192.168.56.112/mydb -u myusername -pmypassword
I can also start my meteor app. using:
MONGO_URL="mongodb://myusername:mypassword#192.168.56.112/mydb" meteor
However, when doing the latter, I get an error "ReferenceError: mycollection is not defined".
Can anyone help my to identify why meteor won't connect to mongo?
As per Evgeny's suggestion, the answer is to define a variable for my collection:
Chatrooms = new Meteor.Collection("chatrooms");