Installing MongoDB community edition on Ubuntu [desktop/server]

MongoDB is a free and open-source NoSQL document-oriented database program designed for high volume data storage and management. It stores data as JSON-like documents as schemas and is one of the fastest database program out there. MongoDB is designed and developed by MongoDB Inc in 2009, since then the open-source community crafted it to be one of the fastest leading technology in the data industry and is well known for its faster data access and easier NoSQL support.

Installing MongoDB 3.6 in Ubuntu

We’ll be installing MongoDB 3.6 community edition in Ubuntu. Follow the instructions carefully step by step to complete the installation.
Get your ubuntu system ready and fire up a terminal by pressing ctrl + alt + T.

  1. 1. Importing the public key used by the Ubuntu package management system

    The Ubuntu package management tools ensure package consistency and authenticity by requiring that distributors sign packages with GPG keys. Paste the following command into your terminal to import the MongoDB public GPG Key.

    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5


  2. 2. Create a list file for MongoDB

    Create the list file mongodb-org-3.6.list in the directory /etc/apt/sources.list.d/ using the following command.

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


  3. 3. Update the local package database

    The following command will download the package lists from the repositories and “updates” them to get information on the newest versions of packages and their dependencies.

    sudo apt-get update


  4. 4. Install the MongoDB packages

    Type the following command in the terminal to install the latest stable version of MongoDB in your computer.

    sudo apt-get install -y mongodb-org

    Once the installation completes. type the following command to ensure MongoDB was successfully installed.

    mongo --version

    you should get the latest version number of the installed MongoDB shell as output.

Running MongoDB

Type the following command to start the MongoDB server in the default port 27017.



sudo service mongod start

You should be able to see the log data and in there you can see the port it is running on.

PS: Don’t worry if the service start process shows any error, it might be probably because the mongod service will be already running in the same port.

Continue to set up your MongoDB admin and user accounts on our next post.
Getting Started with MongoDB – Setting up admin and user accounts.


Community Lead with a demonstrated history of working in a non-profit organization. Skilled in Python, Public Speaking, Graphic Design, Writing, and Android Development. Strong community and social services professional with a Bachelor's degree focused in Computer Science from Sahyadri College of Engineering and Management.