0
votes

I'm trying to connect to a mongodb database remotely.

I have the following information:

  1. mongo DB on x.x.xxx.xxx
  2. Username: tempUser
  3. Password: tempPass
  4. Host: localhost
  5. port: 27017
  6. needed port forwarding in order to access the DB as port 27017 is not open.

I've already tried to connect from console but I fail.

Is there a way to connect from Compass while I forward the port?

2

2 Answers

0
votes

If the port is open you can connect it with this command:

mongo --host ip -u user name -p password
0
votes

When you want to connect to your instance from your workstation anywhere , ssh tunnelling is the way to go.

To use SSH Tunnel While creating a connection on MongoDB Compass , you need to choose it from the drop down box for the other text boxes to show up. Image for post The upcoming fields are pretty standard SSH information , nothing specific for MongoDB.

enter image description here

enter image description here

enter image description here