Technoracle
    Facebook Twitter Instagram
    • Sitemap
    • Privacy Policy
    • Disclaimer
    • Term of Services
    Facebook Twitter Instagram Pinterest Vimeo
    TechnoracleTechnoracle
    • Tutorials
      • Amazon Cloud
      • Google Cloud
    • How To
    • Blog
    • About
    Subscribe
    Technoracle
    Home»How To»How to Install MongoDB on Ubuntu 20.04 [Step by Step]
    How To

    How to Install MongoDB on Ubuntu 20.04 [Step by Step]

    Rajesh ShivamBy Rajesh ShivamApril 23, 2021No Comments3 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Install MongoDB on Ubuntu 20.04
    Share
    Facebook Twitter LinkedIn Pinterest Email
    Install MongoDB on Ubuntu 20.04
    MongoDB Installation Steps

    MongoDB is an open-source document database for modern web applications. In this article, I will cover step by step guide to install MongoDB on Ubuntu 20.04.

    So let’s dive in.

    Page Contents

    • MongoDB installation Steps
      • Step 1: Installing MongoDB
      • Step 2: MongoDB starting and Database Testing
      • Step 3: MongoDB Quick Commands
      • Conclusion

    MongoDB installation Steps

    Step 1: Installing MongoDB

    You can download MongoDB stable version from the ubuntu repository, but it may not be the latest version. To download the latest version, run the following command:

    $ curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -

    This command will return OK. Run the following command, which creates a file in the sources.list.d:

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

    Now run following commands to update all the packages:

    $ sudo apt update
    $ sudo apt install mongodb-org

    Press Y and then ENTER to confirm that you want to install the package. After command finishes, MongoDB installed on your Ubuntu.

    Step 2: MongoDB starting and Database Testing

    To start the MongoDB service, run following command:

    $ sudo systemctl start mongod.service

    To check MongoDB status, run following command:

    $ sudo systemctl status mongod

    This command will return following output:

    Output
    ● mongod.service - MongoDB Database Server
         Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
         Active: active (running) since Tue 2021-05-06 16:27:07 UTC; 2s ago
           Docs: https://docs.mongodb.org/manual
       Main PID: 37128 (mongod)
         Memory: 64.8M
         CGroup: /system.slice/mongod.service
                 └─37128 /usr/bin/mongod --config /etc/mongod.conf

    If the service is running perfectly, enable the MongoDB service to startup at boot. Run following command:

    $ sudo systemctl enable mongod

    To check the database operational or not, you can use the following command.

    $ mongo --eval 'db.runCommand({ connectionStatus: 1 })'

    Here, connectionStatus parameter will check the database connectivity and return the value. Parameter 1 is for server, if it is properly working or not.

    Output will be:

    Output
    MongoDB shell version v4.4.0
    connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
    Implicit session: session { "id" : UUID("1dc7f67x-0az5-4864-g9c3-8g2db7ol9g43") }
    MongoDB server version: 4.4.0
    {
        "authInfo" : {
            "authenticatedUsers" : [ ],
            "authenticatedUserRoles" : [ ]
        },
        "ok" : 1
    }

    Here, Database is running under port no 27017 and the server address is 127.0.0.1 (localhost).

    Step 3: MongoDB Quick Commands

    To check the MongoDB services status use systemctl command.

    $ sudo systemctl status mongod --> To check Mongo Status
    $ sudo systemctl stop mongod --> To Stop Mongo Services
    $ sudo systemctl start mongod --> To Start Mongo Services
    $ sudo systemctl restart mongod --> To Restart Mongo Services
    $ sudo systemctl disable mongod --> To disable automatic startup on boot
    $ sudo systemctl enable mongod --> To enable automatic startup on boot

    Conclusion

    In this article, you have learned how to install MongoDB on Ubuntu 20.04. If you have any doubts or if you like this article, please share it on your social media.

    Read More

    • Install Microsoft Teams on Ubuntu 22.04
      How to Install Microsoft Teams on Ubuntu 22.04 Easily
    • What is Elastic IP and Its Pricing
      What is Elastic IP and Its Pricing in AWS
    • Convert PEM to PPK file
      How to Convert PEM to PPK file [Step by Step Guide]
    • How To Install Composer on Ubuntu 22.04 LTS Easily
    • How to Install Laravel on Ubuntu 22.04 [Super Easy Guide]

    ubuntu tips
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleTop 5 Free Platform to Host Website
    Next Article How to Transfer Domain to AWS Route53
    Rajesh Shivam

    Hello, everyone, I am Rajesh Shivam, I am a full-time freelancer with more than seven years plus experience in different freelancing platforms, in this blog, I am going to provide complete freelancing tips and tricks.

    Related Posts

    How To

    How to Install Microsoft Teams on Ubuntu 22.04 Easily

    February 22, 2023
    Read More
    How To

    What is Elastic IP and Its Pricing in AWS

    February 22, 2023
    Read More
    How To

    How to Convert PEM to PPK file [Step by Step Guide]

    February 22, 2023
    Read More
    Add A Comment

    Leave A Reply Cancel Reply

    Facebook Twitter Instagram Pinterest
    © 2023 Technoracle

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

    Go to mobile version