# Installing MongoDB Community Edition

## Installation Guide

### Installing MongoDB Community Edition involves different steps depending on your operating system. Below is a brief guide for installing MongoDB on Windows, macOS, and Ubuntu Linux.

{% tabs %}
{% tab title="Windows" %}
**1. Windows Installation**

*Prerequisites:*

* Windows Server 2022, Windows Server 2019, or Windows 11 (64-bit).

*Steps:*

1. **Download the Installer:**
   * Visit the [MongoDB Download Center](https://www.mongodb.com/try/download/community) and select the latest version for Windows.
   * Choose the MSI package and click "Download."
2. **Run the Installer:**
   * Locate the downloaded `.msi` file and double-click to run it.
3. **Follow the Installation Wizard:**
   * Choose "Complete" for a full installation.
   * Opt to install MongoDB as a Windows service for automatic startup.
   * Specify data and log directories if different from defaults.
4. **Install MongoDB Shell (`mongosh`):**
   * The installer does not include `mongosh`. Download and install it separately from the [MongoDB Shell Installation Instructions](https://www.mongodb.com/docs/mongodb-shell/install/).
5. **Start MongoDB:**
   * If installed as a service, it starts automatically.
   * To start manually, open Command Prompt as Administrator and run:

     ```arduino
     arduino복사편집"C:\Program Files\MongoDB\Server\8.0\bin\mongod.exe" --dbpath="C:\data\db"
     ```

*For detailed instructions, refer to the* [*official MongoDB documentation for Windows*](https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-windows/)*.*
{% endtab %}

{% tab title="Mac OSX" %}
**2. macOS Installation**

*Prerequisites:*

* macOS 11 or later.
* [Homebrew package manager](https://brew.sh/) installed.

*Steps:*

1. **Install Xcode Command-Line Tools:**
   * Open Terminal and run:

     ```bash
     xcode-select --install
     ```
2. **Install Homebrew (if not already installed):**
   * Follow the instructions on the [Homebrew website](https://brew.sh/).
3. **Tap the MongoDB Homebrew Tap:**
   * In Terminal, run:

     ```bash
     brew tap mongodb/brew
     ```
4. **Update Homebrew:**
   * Run:

     ```bash
     brew update
     ```
5. **Install MongoDB:**
   * Run:

     ```bash
     brew install mongodb-community@8.0
     ```
6. **Start MongoDB:**
   * To run MongoDB as a macOS service:

     ```bash
     brew services start mongodb-community@8.0
     ```
   * To stop the service:

     ```bash
     brew services stop mongodb-community@8.0
     ```

*For detailed instructions, refer to the* [*official MongoDB documentation for macOS*](https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-os-x/)*.*
{% endtab %}

{% tab title="Linux" %}
**3. Ubuntu Linux Installation**

*Prerequisites:*

* Ubuntu 20.04 LTS or later.

*Steps:*

1. **Import the Public Key:**
   * Open Terminal and run:

     ```bash
     sudo apt-get install gnupg curl
     curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor
     ```
2. **Create the List File:**
   * For Ubuntu 20.04 (Focal), run:

     ```bash
     echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
     ```
3. **Reload the Package Database:**
   * Run:

     ```bash
     sudo apt-get update
     ```
4. **Install MongoDB:**
   * Run:

     ```bash
     sudo apt-get install -y mongodb-org
     ```
5. **Start MongoDB:**
   * Run:

     ```bash
     sudo systemctl start mongod
     ```
   * To enable MongoDB to start on system reboot:

     ```bash
     sudo systemctl enable mongod
     ```

*For detailed instructions, refer to the* [*official MongoDB documentation for Ubuntu*](https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/)*.*
{% endtab %}
{% endtabs %}

**Post-Installation:**

* **Verify Installation:**
  * Open the MongoDB shell by running `mongosh` in your terminal or command prompt.
  * To check the MongoDB server version, run:

    ```sh
    db.version()
    ```
* **Configure as Needed:**
  * Modify the MongoDB configuration file (`mongod.conf`) to suit your requirements.

For comprehensive installation instructions and additional details, please refer to the [official MongoDB installation documentation](https://www.mongodb.com/docs/manual/administration/install-community/).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://reactjs.koida.tech/nosql-database/installing-mongodb-community-edition.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
