Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Databases»MongoDB»How to Install MongoDB 4.4 on Ubuntu 18.04 & 16.04 via PPA

    How to Install MongoDB 4.4 on Ubuntu 18.04 & 16.04 via PPA

    By RahulOctober 1, 20203 Mins Read

    MongoDB is a full flexible index support and rich queries database. Mongodb is a NoSQL database. MongoDB provides large media storage with GridFS. Click here for more details about this version of MongoDB.

    Advertisement

    This tutorial will help you to install MongoDB 4.4 community release on Ubuntu 20.04 LTS (Focal), 18.04 LTS (Bionic) and 16.04 LTS (Xenial) systems.

    Step 1 – Setup Apt Repository

    First of all, import GPK key for the MongoDB apt repository on your system using the following command. This is required to test packages before installation

    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 656408E390CFB1F5
    

    Lets add MongoDB APT repository url in /etc/apt/sources.list.d/mongodb.list.

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

    Step 2 – Install MongoDB on Ubuntu

    After adding required APT repositories, use the following commands to install MongoDB on your systems. It will also install all dependent packages required for MongoDB.

    sudo apt update
    sudo apt install mongodb-org
    

    If you want to install any specific version of MongoDB, define the version number as below

    sudo apt install mongodb-org=4.4.1 mongodb-org-server=4.4.1 mongodb-org-shell=4.4.1 mongodb-org-mongos=4.4.1 mongodb-org-tools=4.4.1
    

    Step 3 – Manage MongoDB Service

    After installation, MongoDB will start automatically. To start or stop MongoDB uses init script. Below are the example commands to do.

    sudo systemctl enable mongod.service
    sudo systemctl start mongod.service
    

    Once the service started, check the status by running command:

    sudo systemctl status mongod.service
    

    Installing Mongodb on Ubuntu

    Use the following commands to stop or restart MongoDB service.

    sudo systemctl stop mongod.service
    sudo systemctl restart mongod.service
    
    • How to Work with MongoDB – Read this tutorial

    Step 4 – Verify MongoDB Installation

    Finally, use the below command to check installed MongoDB version on your system.

    mongod --version 
    

    Output:

    db version v4.4.1
    Build Info: {
        "version": "4.4.1",
        "gitVersion": "ad91a93a5a31e175f5cbf8c69561e788bbc55ce1",
        "openSSLVersion": "OpenSSL 1.1.1  11 Sep 2018",
        "modules": [],
        "allocator": "tcmalloc",
        "environment": {
            "distmod": "ubuntu1804",
            "distarch": "x86_64",
            "target_arch": "x86_64"
        }
    }
    

    Also, connect MongoDB using the command line and execute some test commands for checking proper working.

    mongo 
    
    > use mydb;
    
    > db.colors.insert({ "id": 100, "color": "Pink"})
    > db.colors.insert({ "id": 101, "color": "Purple"})
    
    > db.colors.find()
    
      { "_id" : ObjectId("5f75a76194d0a08201f26f25"), "id" : 100, "color" : "Pink" }
      { "_id" : ObjectId("5f75a7d594d0a08201f26f26"), "id" : 101, "color" : "Purple" }
    
    

    More Useful tutorials

    Here is the list of useful tutorials for MongoDB server.

      • Create and Drop database in Mongodb
      • Enable authentication in Mongodb
      • Shell script to backup Mongodb
      • Backup and restore database in Mongodb

      Conclusion

      In this tutorial, you have learned to install MongoDB database server on Ubuntu system.

    database mongo mongodb Ubuntu 16.04 Ubuntu 18.04
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Install and Secure MongoDB on Ubuntu 22.04

    How to Connect MongoDB Database in Python

    Installing MySQL 8.0 on Amazon Linux 2

    How To Install MySQL 8 on Amazon Linux 2

    View 29 Comments

    29 Comments

    1. Riky Perdana on December 18, 2019 4:55 am

      Thanks, it’s very helpful. Less confusing even compared to Atlas guidance, people should recognize this article!

      Reply
    2. vicky on November 14, 2019 5:22 am

      bindip: 183.82.119.115 i added this ip service automatically stopped ?

      Reply
      • Rahul on November 14, 2019 6:54 am

        Hi Vicky, Try with 0.0.0.0 or LAN IP configured on network interface.

        Reply
    3. radhika rathi on September 28, 2019 5:45 am

      how to install mongodb in 18.10 ubantu version ..please tell me

      Reply
      • Rahul on September 30, 2019 7:58 am

        Hi, Ubuntu 18.10 is a nonLTS release, Which supports for a limited time. MongoDB official repo has removed this from the repository.

        You can upgrade to Ubuntu 19.04.

        Reply
    4. Paras chowdhary on August 3, 2019 6:09 pm

      i am getting error saying that unable to locate pacage mongodb-org? how to solve this issue can any one solve this

      Reply
      • nestorgm on November 11, 2019 6:07 pm

        Did you find any solution?

        Reply
        • Rahul on November 12, 2019 7:07 am

          Which OS version are you using?

          Reply
    5. Justin jeosep on February 15, 2019 4:24 am

      Great article! These blog is really useful for beginner’s. Nice Informative Information present on Install mogodb on ubuntu. Thanks for sharing.

      Reply
    6. Deepa on November 26, 2018 11:56 am

      Hi i am trying to setup replication once i add the replication tag and try to start the service is getting failed on Ubuntu 16.04.4 LTS

      Could anyone please help

      Reply
    7. MongoDB on October 31, 2018 4:35 am

      Great Post..!!! This is vital blog , a debt of gratitude is in order for offering to us. It is exceptionally fascinating web journal which is useful for everybody. I value your blog on best blog. Your blog will help us a great deal. In this way, I need to express profound gratitude to you for offering this fundamental blog to us.

      Reply
    8. Kelvin Morris on June 25, 2018 5:05 am

      Hi, Thank you for the post. I think there’s a typo in starting service ‘systmectl’, the correct one is ‘systemctl’

      Reply
      • Rahul K. on June 25, 2018 7:04 am

        Thanks, Kelvin

        I have corrected the typo.

        Reply
        • Rohit on June 25, 2019 11:02 am

          Hello Rahul,

          I’m not able to install mongodb on my ubuntu machine.
          i have tried your steps from this blog but same error occured.
          apt error = sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 9DA31620334BD75D9DCB49F368818C72E52529D4
          [sudo] password for rlabhane:
          Executing: /tmp/apt-key-gpghome.zAgdHqoYjn/gpg.1.sh –keyserver hkp://keyserver.ubuntu.com:80 –recv 9DA31620334BD75D9DCB49F368818C72E52529D4
          gpg: keyserver receive failed: No data

          please give me suggestion.

          Reply
    9. codeasearch on March 12, 2018 8:03 pm

      nice tutorial dude, thanks for sharing. because of you i am able fix the connective issue in mongodb server

      Reply
    10. Raihan on February 19, 2016 8:30 am

      Please help me , I can not install mongodb 🙁

      sudo apt-get install -y mongodb-org
      Reading package lists… Done
      Building dependency tree
      Reading state information… Done
      E: Unable to locate package mongodb-org

      Reply
    11. Andrew Soloninka on January 22, 2016 10:37 pm

      I am running Linux Mint 17.1 which is based on Umbuntu 14.04. When I try to install, I get the following error:

      Could not get lock /var/lib/apt/lists/lock – open (11: Resource temporarily unavailable)
      E: Unable to lock directory /var/lib/apt/lists/

      when I run the command: sudo apt-get update

      Reply
      • Anil on March 16, 2016 9:22 am

        delete /var/lib/apt/lists/lock file using
        sudo rm /var/lib/apt/lists/lock command and run the
        sudo apt-get update command. it willl work fine

        Reply
    12. Sahil on October 24, 2015 11:33 pm

      I am using Ubuntu 15.04. I have followed all the steps above and the installation was successful.
      But, when I try to start the service, I get an error:
      Failed to start mongod.service: Unit mongod.service failed to load: No such file or directory.

      Reply
      • Satarupa Guha on December 24, 2015 1:09 pm

        Reply name to trusty instead of wily in this command:

        echo “deb http://repo.mongodb.org/apt/debian trusty/mongodb-org/3.0 main” | sudo tee /etc/apt/sources.list.d/mongodb.list

        Also install upstart by
        sudo apt-get install upstart-sysv

        Redo everything from scratch.

        Reply
    13. Pumpkin on October 20, 2015 7:20 am

      This ‘tutorial’ is not gonna work for Debian Jessie, since it is using systemd and not the old sysvinit.
      Mongo has as yet not released a package for systemd.
      Creating a mongod.service yourself is not difficult, but I still experience issues with starting the service at boot…

      Reply
      • Max on March 18, 2016 10:18 am

        Hi Pumpkin,

        How did you do then ? My server is based on Debian “Jessie”, and I can’t find a way to install MongoDB properly.
        No tutorials on internet, and I’m afraid to install those recommended by MongoDB-org.

        Did you find any solution ? Or any web site to recommend ?
        Cheers,

        Max

        Reply
    14. Salim on October 7, 2015 5:37 am

      This tutorial is working for debian weezy or raspberry pi?

      Reply
    15. Lorenzo on May 28, 2015 8:04 am

      Hi,
      thank you for this tutorial, but there is a problem when installing Mongo on Ubuntu 14.10 because doesn’t exists the Mongo repository for 14.10 version.

      Could you help me to resolve this problem?

      Thanks.

      Reply
      • Vitali on June 26, 2015 5:14 pm

        Hi Lorenzo,

        I had the similar problem on Linux Mint 17.2. I fixed that by editing the mongodb repository in the source list. You need to replace the Unbuntu’s 14.10 name to 14.04 which is trusty. My final repo looks like this:

        deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse

        Hope that helps,
        Vitali

        Reply
    16. Rakesh P Nehete on April 24, 2015 12:42 pm

      Very nice site always help full .Nice resolution .
      Thank you very much Rahul

      Reply
    17. Rakesh on April 24, 2015 12:40 pm

      very nice site always helpful.

      Reply
    18. Divya on May 15, 2014 8:24 am

      How to run and connect mongo db in browser just like for mysql we use localhost/phpmyadmin. Any suggestions will be helpful

      Reply
      • Rahul on May 15, 2014 10:19 am

        Hi Divya

        You can download phpmoadmin. I will be helpful for you.

        http://www.phpmoadmin.com/file/phpmoadmin.zip

        Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Apt configuration file options /etc/apt/apt.conf
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.