Install MongoDB on Linux — Using *.tgz tarballs — Ubuntu / Debian

I will show you how to install MongoDB on linux step by step, in this tutorial I’m using Ubuntu 18.04 distro. Okay, let’s get started.

Step 1: Download MongoDB

Before you install MongoDB on your linux desktop or server, course you need to have the MongoDB master that you can download it from MongoDB official Website here: https://www.mongodb.com/download-center/v2/community

Choose the community version -> choose your operating system -> download.

Step 2: Installing Prerequisites

Next we need to have:

  • libcurl3 / libcurl4
  • openssl

So, just install them by command below:

or for libcurl 4:

you can use apt or apt-get for this operation, both of them are correct.

Step 3: Extract the MongoDB

Next you need to extract MongoDB that you just downloaded it from the website using terminal and command tar, go to the directory where you just put the master file: (in my case, it is: /home/fiko/Downloads/Programs)

And then execute tar command:

Next, you can do whatever you want to make sure you can access it easly. In my case, I rename the directory name onto mongodb:

And move it to /home/fiko/Applications: (you don’t need to do it if you won’t, I do it to make me easly access it.)

Step 4: Adding Binaries to the Path

Make sure your bin directory of MongoDB registered on PATH, so you can easily access it from any directory via terminal / command line.

Add this to your~/.bashrc file at the end of file: (change the directory to your directory where you installed it.)

Step 5: Setting up MongoDB Configuration

(optional) This is an optional step, But we recommend you to do it. We need to set the configuration of MongoDB. Create a file name mongod.conf in /etc/* directory:

Then paste this this code:

Step 6: Adding Service to System

(Optional) (Recommended) Next, create new file in /lib/systemd/system/* with the name mongod.service. Or you may copy this command:

And paste this to the file:

Step 7: Enable Service

After you registered the service, next you need to enable it, so mongodb will automatically started when you turn on the PC. Enable it by this command:

Step 8: Start the MongoDB

Final step of this installation is to start the mongodb and voila, your MongoDB is ready. Start by this command:

— Completed—

Finish… please leave your comments if you got some trouble.

I wrote these tutorials for myself in future when I forget for the next steps.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store