How can we help?

Search our guides and tutorials, or browse the categories below.

How to Install MongoDB on Ubuntu VPS

171 views Markdown

1.Install Required Tools (gnupg & curl)

sudo apt-get update
sudo apt-get install -y gnupg curl

These are needed to import MongoDB’s GPG key.

2. Import the MongoDB GPG Key

curl -fsSL https://pgp.mongodb.com/server-8.0.asc \
| sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor

3. Add the MongoDB APT Repository

Create the repo file:

echo "deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] \
https://repo.mongodb.org/apt/ubuntu $(lsb_release -sc)/mongodb-org/8.0 multiverse" \
| sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list

This tells Ubuntu where to fetch official MongoDB packages.

4. Update Package Index

sudo apt-get update

5. Install MongoDB

sudo apt-get install -y mongodb-org

6. Start & Enable MongoDB Service

Start MongoDB:

sudo systemctl start mongod

Enable on boot:

sudo systemctl enable mongod

Check status:

sudo systemctl status mongod

7. Verify MongoDB is Running

mongosh

Was this helpful?

Thanks for your feedback!

Still Need Help?

Our support team is here around the clock for anything you can't find above.