Installing MongoDB involves several steps, which vary depending on your operating system. This guide covers installation for Windows, macOS, and Linux (Ubuntu).
# Add MongoDB bin folder to PATH (PowerShell) $env:Path += ";C:\Program Files\MongoDB\Server\4.4\bin"
Using Homebrew:
# Tap the MongoDB Homebrew Tap
brew tap mongodb/brew
# Install MongoDB
brew install mongodb-community
# Start MongoDB as a service
brew services start mongodb-community
# Import the public key
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
# Create a list file for MongoDB
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
# Reload local package database
sudo apt-get update
# Install MongoDB packages
sudo apt-get install -y mongodb-org
# Start MongoDB
sudo systemctl start mongod
After installation, verify your installation by running MongoDB:
mongo
This command should start the MongoDB shell, indicating a successful installation.
Now that you have MongoDB installed, you’re ready to learn about the basic concepts and start using the database. Proceed to the next section to understand the fundamental concepts of MongoDB.