27017 - MongoDB
Usage
Install MongoDB Shell. If you're using a modern MongoDB deployment, you might need mongosh (the newer Mongo shell):
# MongoDB shell
sudo apt update
sudo apt install mongodb-clients
# Mongosh
curl -fsSL https://pgp.mongodb.com/server-6.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor
echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/debian bullseye/mongodb-org/6.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt update
sudo apt install -y mongodb-mongoshThe hosted MongoDB service should give you a connection string, typically in this format:
mongodb+srv://<username>:<password>@<cluster-url>/<dbname>?retryWrites=true&w=majority
# non-SRV (direct host and port access):
mongodb://<username>:<password>@<host>:<port>/<dbname>Connect using the shell (wrap the connection string in single or double quotes if there are special characters):
# mongo (older shell)
mongo "mongodb://username:password@host:port/dbname"
# mongosh (preferred):
mongosh "mongodb+srv://username:password@cluster-url/dbname"Last updated
Was this helpful?