How to Install MongoDB on Windows, Linux & Mac | MongoDB Zero to Hero (Day 3)

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:

https://www.mongodb.com/try/download/community

Select:

  • Version → Latest
  • OS → Windows / Linux / macOS
  • Package → Default

3. Install MongoDB on Windows

  1. Download the .msi file
  2. Double click to start installation
  3. Choose Complete Setup
  4. Tick Install MongoDB as a Service
  5. 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 🔥

Chakrapani U

Hi, I’m Chakrapani Upadhyaya, an IT professional with 15+ years of industry experience. Over the years, I have worked on web development, enterprise applications, database systems, and cloud-based solutions. Through this blog, I aim to simplify complex technical concepts and help learners grow from beginners to confident, industry-ready developers.

Previous Post Next Post

نموذج الاتصال