Introduction:

MongoDB is a popular NoSQL database management system known for its flexibility and scalability. It’s commonly used in modern web development and other applications requiring high-performance data storage. This guide will walk you through the steps to install MongoDB on Ubuntu 22.04.

Prerequisites:

Before you begin, make sure you have the following:

  1. Access to a terminal on your Ubuntu 22.04 system.
  2. Sudo privileges or access to the root account.
  3. An internet connection to download packages.

Installation Steps:

Step 1. Import MongoDB GPG Key:

Use curl to download the MongoDB GPG key and sudo gpg to save it in the appropriate location.

  curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \

sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \

–dearmor

Step 2. Add MongoDB Repository:
Depending on your Ubuntu version, choose the appropriate repository configuration:

For Ubuntu 22.04 (Jammy Jellyfish):

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

Step 3. Update Package Lists:

Run sudo apt update to refresh the package lists with the newly added MongoDB repository.

sudo apt update

Step 4.  Install MongoDB:

Use sudo apt install to install MongoDB on your system.

 sudo apt install mongodb-org

Step 5. Verify Installation:

Confirm that MongoDB is installed by checking the version.

 mongod –version

Step 6: Start MongoDB Service:

Use sudo systemctl to start the MongoDB service.

sudo systemctl start mongod

Step 7. Enable MongoDB Service at Boot:

Ensure MongoDB starts automatically on system boot.

sudo systemctl enable mongod

Conclusion:

You’ve successfully installed MongoDB on your Ubuntu 22.04 system. You can now start using MongoDB by accessing the MongoDB shell (mongosh) or through MongoDB Compass. Remember to refer to the MongoDB documentation for more advanced configurations and usage.

Leave a Reply