📘 Installing MongoDB
MongoDB can be installed on various operating systems. Below are instructions for installing MongoDB Community Edition on Windows, macOS, and Linux (Ubuntu).
✅ 1. Installing MongoDB on Windows
- Download MongoDB Installer:
Visit: MongoDB Community Download
Choose:- Version: Latest
 - Platform: Windows
 - Package: MSI
 
 - Run Installer: Choose Complete setup and ensure “Install MongoDB as a Service” is checked.
 - Set Environment Variable (optional):
Add MongoDB’sbinfolder to PATH:C:\Program Files\MongoDB\Server\<version>\bin - Start MongoDB:
Open Command Prompt and run:mongod
 
🍏 2. Installing MongoDB on macOS
- Install Homebrew:
      
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - Install MongoDB:
      
brew tap mongodb/brew brew install mongodb-community@7.0 - Start MongoDB:
      
brew services start mongodb/brew/mongodb-community
 - Test: Run 
mongoshin terminal 
🐧 3. Installing MongoDB on Ubuntu (Linux)
- Import MongoDB Public Key:
      
wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | sudo apt-key add - - Add MongoDB Repository:
      
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 - Update & Install:
      
sudo apt update sudo apt install -y mongodb-org - Start & Enable MongoDB:
      
sudo systemctl start mongod sudo systemctl enable mongod - Verify Installation: Run 
mongoshormongod --version 
🛠️ Common MongoDB CLI Commands
| Command | Description | 
|---|---|
| mongod | Starts the MongoDB server | 
| mongosh | Opens MongoDB shell | 
| mongo --version | Shows installed version | 
| brew services start mongodb-community | Starts MongoDB service (macOS) | 
| sudo systemctl status mongod | Checks MongoDB service status (Linux) | 
0 Comments