How to connect mongodb with url - mongodb

I am new to mongodb.
I have db url, and I want to connect to that server from my ubuntu terminal and access data on terminal.
can anyone please help me how to connect?

Assuming you have the URI and the mongo shell installed, you can connect using the following command:
mongo <uri>
For example, if you want to log in as admin with the password mypassword through example.com on the port 27017, you can do:
mongo mongodb://admin:mypassword#example.com:27017/?authSource=admin
See:
how can I connect to a remote mongo server from Mac OS terminal

If mongodb version is 5.x.x
mongosh --host ip

Related

Can I restart mongodb server through mongo shell?

Can I restart a MongoDB server through the mongo CLI client?
You can't stop and start (restart) it from the client. As i.kimiko already mentioned, you can shut it down on your client with db.shutdownServer() through a mongo shell database methods documentation 3.6.0
But then you'd still have to connect to the server and restart it from there with sudo service mongodb start for example.
You can shutdown server via client.
mongo --host "hostname where server or IP" --port "port of mondodb server" --username "username" --password "password"
use admin
db.shutdownServer()
link to documentation about db.shutdownServer() mongodb 3.6.0
After that you may up that server via other service\tool (from a host machine when a mongodb server installed), like cron for example or using systemd unit.

Connecting to mongolab db in the shell, but not in Robomongo

I am trying to connect to a MongoLab DB using the credentials and user I set up. I chose the AWS instance using the 500mb of storage (the free Sandbox version). It said it was 3.0.x for Mongo (showing 3.0.9 in MongoLab).
On my environment I am running MongoDB shell version: 3.2.1
Using the command:
mongo ds011111.mongolab.com:11111/mydbname -u dbname -p dbpass
in the shell, I am able to connect to the DB just fine. However, when trying to connect through Robomongo, I am not. I am using the same username, password, database name, host and port. When I run the test, it connects to the host and port just fine, but it says Authorization Fails (this should not be, as I was just authorized to connect in the shell).
What is going?
There is nothing wrong. Just RoboMongo 0.8.x does not support Mongo 3.0+. You can download 0.9 RC4.

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.

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/).

How can I connect to local Meteor's mongodb

How can I connect to the local Meteor's local mongoDB? Fyi, I want to use robomongo as the client. Where can I get the authentication details etc?
I'm using robomongo too
1) Just open robomongo,
2) Create new connection,
3)Give address localhost and port 3001
4) Click connect
Note: Meteor must be running to access the database
While you are creating new connection there is an authentication tab,there u can create username and password for db
enter command meteor mongo in the project directory while you are running the project. it will connect to a mongo shell of the project where you can see the mongo url.
example:
$ meteor mongo
MongoDB shell version: 2.4.9
connecting to: 127.0.0.1:3001/meteor