1. Retrieve your MongoDB Connection String: This can typically be found in the MongoDB hosting interface.
1. Install MongoDB Client: If you haven’t installed MongoDB client, you will need to install MongoDB client on your local machine.
For example:
- MacOS: `brew install mongodb`
- Ubuntu: `sudo apt-get install mongodb`
1. Connect: Using the retrieved MongoDB Connection String, you can connect to the MongoDB from your terminal.
Example:
`mongo “mongodb+srv://cluster0.mongodb.net/test” —username myUsername`
Here, replace mongodb://cluster0.mongodb.net/test with your connection string and myUsername with your username.
1. Enter Password: Upon connecting, you will be prompted to enter your password.
1. You’re In! You’re now connected to your MongoDB Database server.
Alternatively, you can use MongoDB’s unified, cloud-based DBaaS platform MongoDB Atlas for both hosting the MongoDB cluster(s) and connecting them with your application.
Also note, MongoDB Compass can be used to connect remotely in the UI environment. It’s MongoDB’s GUI for querying, visualizing, and interacting with your MongoDB data.
Remember, in shared hosting environments usually cloud providers restrict the direct connection to db for security reasons so always check with them if you are having trouble connecting.
Make sure that the IP from which you are connecting is white listed in MongoDB server. In a production system, it is usually not recommended to expose MongoDB ports to the internet directly. A VPN or a SSH tunnel would be a much safer solution.