Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect mongodb with url

Tags:

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?

like image 631
Amir Avatar asked Oct 14 '25 03:10

Amir


2 Answers

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:[email protected]:27017/?authSource=admin

See: how can I connect to a remote mongo server from Mac OS terminal

like image 192
suspiciousfish Avatar answered Oct 21 '25 02:10

suspiciousfish


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

like image 44
andrei Avatar answered Oct 21 '25 02:10

andrei