Install MongoDB on Ubuntu 22.04

This guide provides step-by-step instructions for installing MongoDB on Ubuntu. MongoDB is a NoSQL database that offers high performance, high availability, and easy scalability.

Prerequisites

Get Started

sudo apt update

This command will refresh the package lists and update any outdated packages on your system.

sudo apt install gnupg curl

This command will download and install the required packages from the Ubuntu repositories.

curl -fsSL https://pgp.mongodb.com/server-7.0.asc | sudo apt-key add -

This command fetches the MongoDB GPG key and adds it to your list of trusted keys.

echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs) mongodb-org 7.0" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list

This command adds the MongoDB repository to your apt sources list, allowing you to install MongoDB from there.

sudo apt update
sudo apt install mongodb-org

This command will download and install MongoDB along with its dependencies.

sudo systemctl start mongod
sudo systemctl enable mongod
sudo systemctl status mongod

You should see an output indicating that MongoDB is active and running.

mongod --version

This command displays the version of MongoDB installed on your system.

Finished

Congratulations! You have now installed MongoDB on your Ubuntu machine. MongoDB is ready to be used, allowing you to leverage its powerful NoSQL database capabilities for your projects and applications.


Revision #1
Created 17 September 2024 17:42:53 by Liam
Updated 17 September 2024 17:42:57 by Liam