How to install mongodb on ubuntu 20.04

MongoDB is a document database used in many modern web applications. It is classified as a NoSQL database because it does not rely on a traditional table-based relational database structure.

Instead, it uses JSON-like documents with dynamic schemas, meaning that, unlike relational databases, MongoDB does not require a predefined schema before you add data to a database. You can alter the schema at any time and as often as is necessary without having to set up a new database with an updated schema.

In this tutorial you’ll install MongoDB on an Ubuntu 20.04 server, test it, and learn how to manage it as a systemd service.

To install MongoDB on Ubuntu 20.04, you can follow these steps:

  1. Import the MongoDB GPG Key:

    Open a terminal and import the MongoDB GPG key to ensure the packages are authentic.

                    
                        wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo gpg --dearmor -o /usr/share/keyrings/mongodb-archive-keyring.gpg
                    
                

  2. Add the MongoDB Repository:

    Add the MongoDB repository to your system's list of sources.

                    
                        echo "deb [signed-by=/usr/share/keyrings/mongodb-archive-keyring.gpg] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
                    
                

  3. Update the Package List:

    Update the package list to include the MongoDB packages.

                    
                        sudo apt-get update
                    
                

  4. Install MongoDB:

    Install the MongoDB packages.

                    
                        sudo apt-get install -y mongodb-org
                    
                

  5. Start MongoDB:

    Start the MongoDB service.

                    
                        sudo systemctl start mongod
                    
                

    You can also enable MongoDB to start on boot:

                    
                        sudo systemctl enable mongod
                    
                

  6. Verify MongoDB Installation:

    Check the status of the MongoDB service to ensure it's running without any issues.

                    
                        sudo systemctl status mongod
                    
                

    You should see a message indicating that MongoDB is active and running.

  7. Now, MongoDB should be installed on your Ubuntu 20.04 system. You can interact with MongoDB using the mongo shell or connect to it through your preferred programming language.

How To Create SSH Keys with OpenSSH on macOS, Linux, or Windows Subsystem f …

Creating SSH keys with OpenSSH on macOS, Linux, or Windows Subsystem for Linux (WSL) involves a few simple steps. Here's a guide: Open Terminal (macOS/Linux) or WSL (Windows), Generate SSH Key Pair, Generate SSH Key Pair, Verify SSH Key Generation,Vi …

read more

Top 50+ Linux Commands

Linux is a powerful operating system with a rich set of commands that allow you to control nearly every aspect of the system. Here is a list of over 50 Linux commands that you should know, including some of the most important ones. beginning of what …

read more