How to Install MongoDB on Windows, Linux & Mac | MongoDB Zero to Hero (Day 3)
In this article, you will learn how to install MongoDB step by step. This is a very important setup for practicing all upcoming concepts.
1. What We Will Learn
- Download MongoDB
- Install MongoDB
- Start MongoDB Server
- Open Mongo Shell
- Verify Installation
2. Download MongoDB
Go to the official website:
Select:
- Version → Latest
- OS → Windows / Linux / macOS
- Package → Default
3. Install MongoDB on Windows
- Download the .msi file
- Double click to start installation
- Choose Complete Setup
- Tick Install MongoDB as a Service
- Click Next → Install
MongoDB will install successfully ✅
4. Install MongoDB on Linux (Ubuntu)
sudo apt update sudo apt install -y mongodb
Start MongoDB:
sudo systemctl start mongodb
5. Install MongoDB on macOS
Using Homebrew:
brew tap mongodb/brew brew install mongodb-community
Start MongoDB:
brew services start mongodb-community
6. Start MongoDB Server
Open command prompt or terminal and type:
mongod
This starts the MongoDB database server.
7. Open MongoDB Shell
Open a new terminal and type:
mongosh
If you see this, MongoDB is working:
test>
Congratulations 🎉 MongoDB is installed successfully.
8. Verify Installation
show dbs
This command shows available databases.
9. Common Errors & Solutions
Port Already in Use
MongoDB service is already running. No need to start again.
'mongod' not recognized
Add MongoDB bin folder to Environment Variables.
Permission Denied (Linux/Mac)
Use sudo before commands.
10. Folder Structure Created by MongoDB
- data → stores database files
- log → stores logs
- bin → MongoDB executables
Conclusion
In this article, you learned:
- How to download MongoDB
- Install on Windows, Linux, macOS
- Start MongoDB server
- Open Mongo shell
- Verify installation
- Fix common errors
Now your system is ready for MongoDB practice.
In the next article, we will learn MongoDB Database, Collection & Document – Core Concepts.
Your MongoDB Zero to Hero journey is getting practical 🔥