Connect to Mongo from Meteor - mongodb

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");

Related

Connect external mongodb with private key ( file.pem ) and user without mongo_url

Hello I’m new Meteor !!!
I have only private key (file.pem), user, ip:port
I don’t know how to connect with meteor run on local machine
First try to connect with some local client, terminal or robomongo. After you managed to do that, you can look into ways to connect your meteor application to external mongodb.
Also since meteor coming with its own bundled mongo, you should install mongodb in your system and connect your meteor app to this one mongo first.

why is MongoDbB not running and not working?

i installed MongoDB compass and when i try to connect with hostname localhost ,Port: 27017
i receive this error: connect ECONNREFUSED 127.0.0.1:27017.
I also looked in Task manager and MongoDB was not running. Thank you for your help
MongoDB compass is only a client. you should install the mongo community edition (for development setup) and then use compass client to access it.
https://docs.mongodb.com/manual/installation/
MongoDB compass is graphical user interface (GUI) for the actual mongoDB. That is to say, you need an actual mongoDB running in order to be able to interact with the data through the GUI.
Once you have the database install, you can start it by typing the command mongo in the shell. There after you should be able to return to mongoDB compass and view the data in you database (I should mention, I'm assuming that you're running on the default port and on your local machine).

how to show my users collection with mongodb

I'm sorry for this (peraphs) stupid question ... I install meteor and mongodb in my windows computer and i start to write some apps. I don't understand how to use mongo for shoving my db app ... i open one shell in my app dir and launch mongod, in one more shell in the same folder i start mongo.
show dbs
local
use local
switched to db local
show collections
startup_log
system.indexes
Where are my collections? Where is users collection?
When your app is running use this command on a separate command line mongo 127.0.0.1:3001
Meteor keeps the collections in this server. After you run mongo on this server, by writing use meteor you can use db specific to your running app. And then you can display your collections with db.getCollectionNames()
Meteor uses a library called Minimongo that's why it doesn't display if you run show dbs on your mongo shell.
By default it points to port 3001 hence if you are using Robomongo you can just make the set up to watch that port.
To display all your MongoDB collections using the shell, you may check this answer:
How to list all collections in the mongo shell?
You may also use a MongoDB GUI Tool such Robomongo

In Meteor.js, how would I have two development projects use the same Mongo instance?

I would like to have two separate applications use the same Mongo DB instance, and since I am developing them at the same time I would like to be able to share the same development DB instance.
I realize that each instance of Meteor would have to run on it's own port. Is there a way to force meteor or mrt to connect to a local socket like the system version of MongoDB?
Yeah, you can just start meteor with the MONGO_URL parameter like:
$ MONGO_URL="mongodb://localhost:27017/myapp" meteor
or
$ MONGO_URL="mongodb://localhost:27017/myapp" meteor --port 4000
This assumes you have mongodb installed on your system. See this question for ways to make this process a little easier by using environment variables or a start script.
David's answer is in the right direction, but threw me off a little. Instead, we're doing this to start the first app as normal:
$ meteor
Then to start the second app and connect to the database of the first, we're doing:
$ MONGO_URL="mongodb://localhost:3001/meteor" meteor --port 3002
The key here is that meteor starts its own mongo instance on port 3001, and we can connect to that directly from a second meteor instance. David's answer uses your system's mongo for both apps.

How is MongoDb installed by Meteor?

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