Installing MongoDB on Different Platforms
Installing MongoDB on Different Platforms
- Windows:
- Download MongoDB: Go to the MongoDB Download Center and download the Windows installer.
- Run Installer: Execute the downloaded
.msifile and follow the installation wizard. - Setup Environment: Add MongoDB’s
bindirectory to the PATH environment variable. - Start MongoDB: Open Command Prompt and run
mongodto start the server.
- macOS:
- Install Homebrew (if not installed): Run
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)". - Install MongoDB: Run
brew tap mongodb/brewand thenbrew install mongodb-community. - Start MongoDB: Use
brew services start mongodb-community.
- Install Homebrew (if not installed): Run
- Linux:
- Import MongoDB Public Key: Run
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -. - Create List File: Run
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu focal 10gen" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list. - Install MongoDB: Run
sudo apt-get updateand thensudo apt-get install -y mongodb-org. - Start MongoDB: Use
sudo systemctl start mongod.
- Import MongoDB Public Key: Run
Setting up MongoDB Compass
- Download MongoDB Compass: Visit the MongoDB Compass Download Page and download the appropriate version for your OS.
- Install Compass: Follow the installation instructions for your platform.
- Connect to MongoDB: Open Compass and connect to the MongoDB server using the default connection settings (
mongodb://localhost:27017).