Skip to content

Install MongoDB in Ubuntu 18.04 and 19.04

The steps given in this post are tested on Ubuntu 19.04, however, they are the same for other Ubuntu versions such as 18.04, 16.04, 15.04, 14.04.

If you want to skip all the blah blah and get the MongoDB installation on Ubuntu in quick time, run the following commands one by one.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo service mongod start

That works like a charm, doesn’t it?

If you want to learn what the above commands are, please read below.

Import the MongoDB public GPG Key

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

Create a source list for MongoDB

echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list

Update the local system’s package database

sudo apt-get update

Install MongoDB packages

sudo apt-get install -y mongodb-org

Start MongoDB Service

sudo service mongod start

See also  Convert MongoDB ObjectId to timestamp and vice versa

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.