Ad Code

Responsive Advertisement

✨ MongoDB - Installation

📘 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

  1. Download MongoDB Installer:
    Visit: MongoDB Community Download
    Choose:
    • Version: Latest
    • Platform: Windows
    • Package: MSI
  2. Run Installer: Choose Complete setup and ensure “Install MongoDB as a Service” is checked.
  3. Set Environment Variable (optional):
    Add MongoDB’s bin folder to PATH:
    C:\Program Files\MongoDB\Server\<version>\bin
  4. Start MongoDB:
    Open Command Prompt and run:
    mongod

🍏 2. Installing MongoDB on macOS

  1. Install Homebrew:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
          
  2. Install MongoDB:
    brew tap mongodb/brew
    brew install mongodb-community@7.0
          
  3. Start MongoDB:
    brew services start mongodb/brew/mongodb-community
  4. Test: Run mongosh in terminal

🐧 3. Installing MongoDB on Ubuntu (Linux)

  1. Import MongoDB Public Key:
    wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | sudo apt-key add -
          
  2. 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
          
  3. Update & Install:
    sudo apt update
    sudo apt install -y mongodb-org
          
  4. Start & Enable MongoDB:
    sudo systemctl start mongod
    sudo systemctl enable mongod
          
  5. Verify Installation: Run mongosh or mongod --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)

Post a Comment

0 Comments