How to connect mongodb clients to local Meteor MongoDB - mongodb

How can I connect Robomongo (or any other mongodb client) to the mongodb instance that is created by my local Meteor application?

Ensure Meteor is running on localhost. Open a terminal window and run meteor command. It will start running on localhost:3000 if you have not changed to port.
While it is running, open a separate terminal window and run meteor mongo command. This will open up a MongoDB shell and tell you what port it is connecting to This is normally 3001 as of version 0.7.1.1 or 3002 if earlier. It will say something like 127.0.0.1:3001/meteor
Go to Robomongo (or your favorite mongodb client software) and create a new connection, making sure to change the connection address to localhost and the given the port number. No need to additionally define /meteor if your client does not insist on a default database.
Also as pointed out in https://stackoverflow.com/a/22023284/1064151 some drivers may need specific line endings, delimeters or other character flow. For example, ObjCMongoDB a C based driver wants the url to be 127.0.0.1:3001/ with that extra / at the end, or it won't work. So make sure you check the documentation for your driver/client.

Easiest way to get the current configuration details is to use the following command
meteor mongo -U
This will give you the connection string

From terminal run following command
meteor mongo -U
That will show you the local host IP address and in which port you application is running. Now run the Robomongo and configure as following two field as you got by running the previous command

Use SSH tunneling by the following command :
ssh -L 3001:localhost:3001 user-name#host
It forwards connections from your local port 3001 to localhost:3001 on your server. Now we can simply connect to our database.
Create a Robomongo connection on your localhost and hit Test (Out of two checks, Authentication may fail) :

I'm using ObjCMongoDB, a C based mongoDB driver. With the new update instead of using the previous 127.0.0.1:3002 to connect to my localhost running meteor's mongodb, I now need to use 127.0.0.1:3001/ with the collection name still being meteor.collection. The important change is the port from :3002 to :3001/. Remember the /, it is critical for the connection.

This worked for me,Before connecting make sure meteor is running.
I am using Robomongo to connect. Create new connection and add
Address as : localhost;
port as: 3001

I'm too using Robomongo and before the latest update V0.7.1,i used port 3002 to connect,as #Serkan Durusoy suggest's for the latest update it is working for 3001 port

#imal365 answer is perfect. Just to add my insight on it:
I realized that the default Meteor Mongo port number is the port number of the application with 1 added to it (as of version 0.7.1.1). In my case, I was running Meteor on port 1337 with the command meteor --port 1337 and my Meteor Mongo port was 1338.

Related

Connect mongo with meteor in production

I have deployed my meteor application on localhost for demo purpose by following what was mentioned here.
$export MONGO_URL='mongodb://localhost'
$ export PORT=3000
$ export ROOT_URL='http://example.com'
$ node main.js
I have had a bunch of collections in my meteor's mongo instance while development and need to move it to the new db that the deployed version connects to. I've taken a mongo dump of that and I know how to restore it. My question is, how exactly do I connect to the mongo db in order to do this?
I've tried:
mongo localhost
mongo localhost:3000
mongo -U localhost
They don't seem to work.
NOTE -
I do not want to run the mongo in development environment using meteor mongo. I have to deploy this in the client machine.
You can use the Meteor command line tools to attach to your local meteor instance.
meteor mongo
Taken from https://docs.meteor.com/commandline.html#meteormongo
Also, I think your commands didn't work 'cause the meteor mongo instance is hosted on port 3001 instead of 3000. Port 3000 hosts the actual meteor app, 3001 is the mongo instance.
As k.chao.0424 says you can use meteor mongo to connect to the mongo db via terminal or command line if you are using windows. But as i see you used the port 3000 for mongodb. I suggest you a simple way you just run the follwing command to run meteor and mongo db just write on your terminal:-
meteor
or if you are using ubuntu and any permission issues than write:-
sudo meteor
It will automatically run your project on 3000 port and your mongdb in 3001 port as by default after running app you can connect with mongodb via following command:-
meteor mongo
Hope this will help!

Connect mongodb server via robomongo from another PC

I am using mongodb database for my meteor app. I want to access it from another pc. I have mounted my local as a virtual drive on other PC using ssh. Now I want to connect to mongodb via robomongo. I have given the address as 192.168.1.2:4001 (ip addr of local : port on which meteor is running +1). But its giving an error 'Unable to connect to mongodb'. How to proceed?
The other way around is to start your meteor on a regular mongo server with this command :
MONGO_URL=mongodb://localhost:27017/nameOfDatabase meteor
Be sure to have a running mongo on localhost and to change the nameOfDatabase.
Now it's just a regular mongoDB server to connect. Also you might need to add login and password to that mongo url and the debug parameter after meteor if you use packages like meteor toys.
Please check mongodb's config file /etc/mongod.conf and comment out bind ip
net:
#bindIp: 127.0.0.1
port: 4001
Restart mongodb service. This will allow mongodb to bind to ip's other than localhost.

How to connect to a remote meteor mongodb using robomongo

I am using Meteor. Which is installed on another server.
I want to access its mongodb from another [Ubuntu Machine].
Now how can I access that mongodb via robomongo or any other tool?
Any guidance or help would be appreciated.
In Robomongo in the upper left:
Click create
In the pop-up window enter the address and port of your Mongo server
Give the connection a name and click save.
Using the Terminal (on the client):
mongo --host <hostname> --port <port>
You have to make sure the port is not blocked on the Ubuntu machine running the Meteor application. Note: when developing a Meteor app the default Mongo port is 3001.

JDBC connection to mongodb running on Meteor server on Cloud 9

I have a Meteor app running on Cloud 9 and I would like to connect to MongoDB from a window app that I am in trial period (DBSCHEMA: http://www.dbschema.com/).
Cloud 9 guys told me that I need my DB to listen to 0.0.0.0:8082.
In cloud9 I started my app using command: $ meteor --port $IP:$PORT.
I also created a db and user that has role "userAdmin" to this database.
In another terminal, at c9, "Meteor mongo" command give me connecting to: 127.0.0.1:8081/meteor
In DBSchema ping to the server is succesfull, but connection is refused.
So, I am trying to change to 0.0.0.0:8082 but I cant figure out how and not sure its going to work.
Any suggestions please?
use environment variable MONGO_URL=your-mongo-server-ip-or-hostname:8082 in meteor and start mongo with port 8082 on 0.0.0.0 with the config file
http://docs.mongodb.org/manual/reference/configuration-options/
Ideally, you should not expose you dB to the outside (so not bind to 0.0.0.0 which exposes the DB on all interfaces including the public IP).
If you want to access it with Robomongo, bind to localhost, and then you should create a ssh tunnel to the server from you local terminal with the command
ssh -L 8082:localhost:8082 your-host
then connect to it with robomongo at localhost:8082 –

Access MongoDB from other server

I have a MongoDB database on my Linux server. I want to access it from another server. I tried to make a connection from my local computer with the Robomongo. The connection is succesfull, but the authentication fails.
How can I get the authentication credentials? Or should I change something in MongoDB before I can acces the database from another server / pc?
Someone else have set up this database, and there is no possibility to ask him this questions.
I have found the solution by my self:
The File etc/mongod.conf has a line 'bind_ip'. In this line, you originally have to add the IP address which you want to access your database. But, it don't work! You should better comment this line.
But, you don't have any authentication now, so you have to add authentication. Here you have an tutorial about this: http://ghosttx.com/2012/03/how-to-connect-to-a-remote-mongodb-server-with-mongohub-for-mac/
When you have done that, you have to enable authentication. You can do this by editing etc/mongod.conf again, and uncomment the line 'Auth = true'.
Now you can connect with you Mongo Database ;)
Ive sorted it by adding ssh option to RoboMongo following this link:
http://www.mongovue.com/2011/08/04/mongovue-connection-to-remote-server-over-ssh/
Im on OSX and connecting to Ubuntu 14 / Mongo 2.6.7 on VPS and when Ive added my ssh details to the Robomongo all seem to work ok (Ive also changed the mongo config to remove the ip_bing and enabled port 27017)
If you do not like to bother with authentication and stuff just make an SSH Tunnel:
ssh -fN -l username -i .ssh/id_rsa -L 9999:localhost:27017 remote.com
Just connect to mongodb on localhost:9999 and it will establish a connection to your mongodb on port 27017 on your server at remote.com.
Run your mongodb with following command to access mongodb from other servers
mongod --port 10945 --bind_ip 0.0.0.0
I was not able to use Robomongo with MongoDB 3.0 too (connecting from a Windows machine to a Linux one, using SSH). The only tool that works for me is MongoChef (http://3t.io/mongochef/).