-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux MongoDB Guide
Mattscreative edited this page Dec 5, 2025
·
3 revisions
Complete beginner-friendly guide to MongoDB on Linux, covering Arch Linux, CachyOS, and other distributions including installation, configuration, and database management.
Arch/CachyOS:
# Install MongoDB
yay -S mongodb-bin
# Or community edition
yay -S mongodbDebian/Ubuntu:
# Add MongoDB repository
wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
sudo apt update
sudo apt install mongodb-orgFedora:
# Add MongoDB repository
# Download from mongodb.comStart MongoDB:
# Enable and start service (recommended method)
sudo systemctl enable --now mongodb
# Check status
systemctl status mongodbConnect to MongoDB:
# Launch MongoDB shell
mongosh
# Or mongo (older versions)
mongoCreate database:
// In MongoDB shell
use mydb
// Insert document
db.collection.insertOne({name: "example"})CRUD operations:
// Create
db.collection.insertOne({key: "value"})
// Read
db.collection.find()
// Update
db.collection.updateOne({key: "value"}, {$set: {new: "data"}})
// Delete
db.collection.deleteOne({key: "value"})Check service:
# Check status
systemctl status mongodb
# Check logs
journalctl -u mongodb
# Check data directory
ls -la /var/lib/mongodbThis guide covered MongoDB installation, configuration, and usage for Arch Linux, CachyOS, and other distributions.
- Database Servers - Database setup
- Development Environment - Development
- MongoDB: https://www.mongodb.com/
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.