Monday, June 10, 2024

How to Install PostgreSQL on Ubuntu 24.04 and Linux Mint


 PostgreSQL, a widely acclaimed open-source relational database management system (RDBMS), can be seamlessly installed on your Ubuntu 24.04 system. Renowned for its robust data management capabilities and exceptional scalability, PostgreSQL caters to a diverse range of applications, from simple websites to large-scale enterprise applications.

This comprehensive guide will walk you through the process of installing PostgreSQL on Ubuntu 24.04, encompassing system updates, package installation, and service configuration.

Step 1: System Update

Before embarking on the installation, it is crucial to update your system. This ensures you have the latest packages and dependencies installed. Execute the following command in your terminal:

$ sudo apt update && sudo apt upgrade -y

Press Enter and allow the update process to complete. Depending on the number of pending updates, this may take a few minutes.

Step 2: Add PostgreSQL Repository

The official PostgreSQL repository enables you to install the most recent PostgreSQL version. However, prior to adding it, you need to install the postgresql-common package. This package encompasses the PGDG (PostgreSQL Global Development Group) repository and utilities for managing PostgreSQL.

Run the following command to install the postgresql-common package:

$ sudo apt install postgresql-common

Once the installation is complete, add the PGDG repository to your system using the following command:

$ sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

This command will add the necessary repository for your specific Ubuntu version.

Step 3: Install PostgreSQL

With the PostgreSQL repository added, refresh the package database again to ensure the latest package list is retrieved. Execute the following command:

$ sudo apt update

With the updated package database, you can proceed with PostgreSQL installation. Use the following command to install the latest PostgreSQL version:

$ sudo apt install postgresql

The installation process will commence and may take a few minutes depending on your internet speed.

Step 4: Start PostgreSQL Service

During the installation process, a Systemd service is created to manage PostgreSQL. To ensure this service is running, use the following command:

$ sudo systemctl status postgresql

This command will display the status of the PostgreSQL service. If the service is not running, you can start it and enable it to start automatically upon system boot. Execute the following commands sequentially:

$ sudo systemctl start postgresql
$ sudo systemctl enable postgresql

The first command will initiate the PostgreSQL service, while the second command will enable it to start automatically in the future.

Congratulations!

You have successfully installed PostgreSQL on Ubuntu 24.04! PostgreSQL is now ready to use for creating databases and managing your data. The next step is to secure and configure PostgreSQL according to your specific requirements. Numerous resources are available online to assist you with this process.

0 comments:

Post a Comment