2️⃣Install MongoDB

If you want to use Mongodb Atlas Cloud Database, you can skip this process. You can choose either locally installed Mongodb Database or Cloude Database which is free.

Use this tutorial to install MongoDB 6.0 Community Edition on LTS (long-term support) releases of Ubuntu Linux using the apt package manager.

Type the command below on the terminal.

sudo apt-get install gnupg curl

On your terminal, please copy and paste below code.

curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
   sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
   --dearmor

Now copy and paste below code to the terminal. please use the code according to your operating system.

echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

Now update the repository.

sudo apt-get update

Now Install the Mongodb.

sudo apt-get install -y mongodb-org

Now start the mongodb service to your server.

sudo systemctl start mongod

Type this command to start mongodb on every start on your server.

sudo systemctl enable mongod

Check whether the mongodb service is running or not.

sudo systemctl status mongod

This is show a success message like below.

 mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor prese>
     Active: active (running) since Mon 2023-08-07 09:38:45 UTC; 6s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 11249 (mongod)
     Memory: 72.5M
        CPU: 662ms
     CGroup: /system.slice/mongod.service
             └─11249 /usr/bin/mongod --config /etc/mongod.conf

That's it. Mongodb is now installed on your system.

Last updated