How to Install MongoDB on Ubuntu
Introduction
MongoDB is a popular NoSQL database for modern applications. This guide shows you how to install MongoDB on your Ubuntu VPS.
Step-by-step Guide
- Import the MongoDB public GPG key
- wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add -
- Add the MongoDB repository
- echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
- Update your package list
- sudo apt update
- Install MongoDB
- sudo apt install -y mongodb-org
- Start and enable MongoDB
- sudo systemctl start mongod
- sudo systemctl enable mongod
- Check MongoDB status
- sudo systemctl status mongod
- (Optional) Test MongoDB shell
- mongosh
Recommendations
- Secure MongoDB by binding to localhost or setting up authentication.
- Regularly back up your databases.
- Keep MongoDB updated for security and performance.
Call To Action
eed a VPS for your MongoDB projects? Check out our hosting plans: https://xernode.com/#pricing