All Tutorials

Your One-Stop Destination for Learning and Growth

How to Install MongoDB and Compass GUI Admin on Windows

MongoDB is a popular NoSQL database management system known for its simplicity, flexibility, and scalability. In this tutorial, we'll walk you through the process of installing MongoDB and the Compass GUI admin tool on your Windows machine.

Prerequisites

Before we begin, make sure that your Windows machine meets the following prerequisites:

  1. You have administrative privileges to install software.
  2. Your system meets the MongoDB minimum requirements.

Installing MongoDB

Follow these steps to download and install MongoDB on your Windows machine:

  1. Download MongoDB: Visit the MongoDB Downloads page and download the latest stable release of MongoDB for Windows.

  2. Install MongoDB: Run the downloaded .msi file as an administrator, follow the on-screen instructions to complete the installation. During the installation process, make sure to select "Custom" installation type and choose "Express Installation." Also, remember the default installation location (usually under C:\Program Files\MongoDB\Server) as we will need it later for Compass setup.

  3. Configure Data Directory: By default, MongoDB stores data in a hidden directory under your user profile. However, it's a good practice to create a separate directory for your MongoDB data. To do this, right-click on the start menu and choose "System properties." Go to the "Advanced" tab, click on the "Environment Variables," and add two new variables:

    • MONGO_DATA_DIR: Set the value to a custom directory (e.g., C:\data\mongodb).
    • MONGODB_INSTALL_DIR: Set the value to your MongoDB installation directory (default is usually C:\Program Files\MongoDB\Server).

Installing Compass GUI Admin

Compass is a popular, open-source GUI tool for managing MongoDB databases. Follow these steps to install Compass on your Windows machine:

  1. Download Compass: Visit the Compass GitHub page and download the latest release of Compass for Windows.

  2. Install Compass: Run the downloaded .exe file as an administrator, follow the on-screen instructions to complete the installation. Make sure to select your MongoDB installation directory during the setup process.

Starting MongoDB and Compass

Now that both MongoDB and Compass are installed, let's start them:

  1. Start MongoDB: Press Win + R, type services.msc, and press Enter to open the Services Manager. Find "MongoDB Community Server" in the list and ensure it is set to "Automatic" and "Started." Close the Services Manager and open a new Command Prompt as an administrator by searching for "cmd" in the Start menu, right-clicking on it, and choosing "Run as administrator." In the command prompt, type mongod --shutsdown to stop MongoDB if it's already running. Then, type mongod --serviceName mongodb --install to install MongoDB as a Windows service and start it.

  2. Start Compass: Press Win + S, type "Compass," and press Enter to open the Compass application. Make sure your MongoDB server is running, then connect to it in Compass by clicking on the "Connect" button and providing the appropriate connection details (usually localhost and the default port 27017).

Congratulations! You have successfully installed MongoDB and Compass on your Windows machine. Now you can start managing your databases using the powerful features of the Compass GUI admin tool.

Published October, 2018