Skip to content
Live $300 credit for new accounts Valid for 60 days from account creation Get started →

MongoDB 8.0

MongoDB is a general-purpose, document-oriented NoSQL database that stores data as flexible JSON-like documents. It is well suited for applications that need rich queries, horizontal scaling, or schemas that evolve over time.

ComponentVersion
MongoDB Community8.0.x
Ubuntu24.04 LTS
ssh ubuntu@<your-vm-ip>

On the first boot, a setup script runs automatically. It creates an admin superuser with a randomly generated password and enables authentication. This takes under 60 seconds.

Track progress:

journalctl -u mongodb-first-boot.service -f

Wait for the service to exit, then disconnect and reconnect. The MOTD on login shows MONGODB 8.0.x — READY when the setup is complete.

sudo cat /etc/mongodb/credentials.txt

This file contains the admin username, password, and connection instructions. It is only readable by root.

MONGO_PASS=$(sudo awk '/^Password:/{print $NF}' /etc/mongodb/credentials.txt)
mongosh -u admin -p "$MONGO_PASS" --authenticationDatabase admin

Expected output:

test>
# Check service status
systemctl status mongod
# Restart
sudo systemctl restart mongod
# View logs
sudo journalctl -u mongod -f

Configuration file: /etc/mongod.conf

Port 27017 is not open externally by default. UFW is enabled and allows SSH (port 22) only.

To allow access from a specific IP:

sudo ufw allow from <trusted-ip> to any port 27017

To connect without opening the firewall (recommended), use an SSH tunnel:

# Run this on your local machine
ssh -L 27017:localhost:27017 ubuntu@<your-vm-ip>
# Then connect locally
mongosh -u admin -p "<password>" --authenticationDatabase admin