Big data algorithms, techniques and platforms — Installing MongoDB

How to install MongoDB


In this page you’ll find instructions to install MongoDB on your computer.

1 Instructions for MacOS users

You’ll need to use commands in the Terminal to install MongoDB.

1.1 Prerequisites

  • Install XCode. You’ll find it for free in the Mac App Store.

  • Install Homebrew, a command-line utility that let’s you install several software applications. Type the following command in the Terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  • Install MongoDB Compass, a MongoDB client that communicates with a MongoDB server and lets you manipulate your MongoDB databases through a graphical interface. You’ll find the installer package at this page.

1.2 Installation

You can watch the following video that details how to install MongoDB, start the server and connect to the server through MongoDB Compass.

The commands used in the video are detailed below.

  • Tap the official MongoDB Homebrew tap with the following command:
brew tap mongodb/brew
  • Type the following command to install MongoDB:
brew install mongodb-community@4.4

1.3 Launch the MongoDB server

Type the following command:

brew services start mongodb-community@4.4

1.4 Launch MongoDB compass

  • Open MongoDB Compass.

  • After few clicks you should land on the “New Connection” page.

  • In the textfield under the message “Paste your connection string (SRV or Standard)”, paste the following URI and click on “Connect”.

mongodb://localhost:27017
  • If everything goes well, you should see a list of databases.

1.5 Stop the MongoDB server

If, for any reason, you want to stop the MongoDB server, type the following command in the Terminal:

brew services stop mongodb-community@4.4

NOTICE

Remember to start the MongoDB server when you need to access your databases using MongoDB Compass.

2 Instructions for Windows users

You can follow the procedure in the following video. You can read a detailed description of the installation steps below.

  • Go to the MongoDB download page and download the installer (.msi file).

  • Double-click the downloaded .msi file and follow the instructions. The procedure will also install MongoDB Compass, a MongoDB client that lets you manage your database through a graphical interface.

  • Once the installation procedure is over, the MongoDB server is automatically started.

  • MongoDB Compass should execute automatically too. After few clicks you should land on the “New Connection” page.

  • In the textfield under the message “Paste your connection string (SRV or Standard)”, paste the following URI and click on “Connect”.

mongodb://localhost:27017
  • If everything goes well, you should see a list of databases.

If, for any reason, you wish to stop the MongoDB server, you can use the Services console and stop the corresponding service, as shown in the video.

NOTICE

Remember to start the MongoDB server when you need to access your databases using MongoDB Compass.