UbuntuUbuntu Based

How To Install pgAdmin on Ubuntu 24.04 LTS

Install pgAdmin on Ubuntu 24.04

pgAdmin is a powerful, open-source management tool for PostgreSQL, one of the most popular relational database management systems. With its user-friendly interface and robust features, pgAdmin simplifies database administration, making it easier to manage complex databases. This guide will walk you through the installation process of pgAdmin on Ubuntu 24.04 LTS, ensuring you can efficiently manage your PostgreSQL databases.

Prerequisites

Before diving into the installation process, ensure that you have the following prerequisites in place:

  • Ubuntu 24.04 LTS: Make sure your system is running this version.
  • Terminal Access: Familiarity with the command line is essential.
  • PostgreSQL Installation: Verify that PostgreSQL is installed on your system. You can check by running psql --version.

Step-by-Step Installation

1. Update System Packages

The first step in preparing your system for pgAdmin is to update your package list. This ensures that you have the latest updates and security patches. Open your terminal and execute the following command:

sudo apt update && sudo apt upgrade

This command updates the package list and upgrades all installed packages to their latest versions. Regularly updating your system helps maintain stability and security.

2. Install PostgreSQL

If PostgreSQL is not already installed, you can do so by executing the following command:

sudo apt install postgresql postgresql-contrib -y

The -y flag automatically confirms the installation of packages. PostgreSQL is essential for pgAdmin to function, as it provides the database backend that pgAdmin manages.

3. Add Public GPG Key

A GPG key is crucial for verifying the authenticity of software packages. To add the public GPG key for pgAdmin, run the following command:

curl -fsSL https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg

This command downloads and adds the GPG key to your system, ensuring that future installations are secure.

4. Add Repository for pgAdmin 4

The next step is to add the official repository for pgAdmin 4. This repository contains the latest versions of pgAdmin and its dependencies. Execute this command:

sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

This command creates a new source list file specifically for pgAdmin and updates your package list again to include packages from this repository.

5. Update Package List Again

After adding the repository, it’s necessary to update your package list once more to ensure that your system recognizes the new packages available from the pgAdmin repository:

sudo apt update

6. Install pgAdmin 4

You can choose to install pgAdmin in different modes: desktop mode, web mode, or both. Depending on your needs, execute one of the following commands:

    • For both modes:
sudo apt install pgadmin4
    • For desktop mode only:
sudo apt install pgadmin4-desktop
    • For web mode only:
sudo apt install pgadmin4-web

Selecting either mode depends on how you prefer to interact with pgAdmin—through a desktop application or via a web browser.

Post-Installation Configuration

After installing pgAdmin, some initial configuration steps are necessary, especially if you opted for web mode. To set up web mode, run the following script:

sudo /usr/pgadmin4/bin/setup-web.sh

This script will prompt you to create an admin user account and configure email settings if needed. Follow the prompts carefully to complete this setup.

Accessing pgAdmin

You can access pgAdmin based on how you installed it:

  • If installed in desktop mode: Launch it from your applications menu.
  • If installed in web mode: Open a web browser and navigate to http://127.0.0.1/pgadmin4. Use the admin credentials created during setup to log in.

Install pgAdmin on Ubuntu 24.04 LTS

Troubleshooting Common Issues

If you encounter problems during installation or while accessing pgAdmin, consider these common issues and their solutions:

  • Error: Unable to locate package: Ensure that you have added the correct repository and updated your package list.
  • Error: GPG key not found: Double-check that you executed the command to add the GPG key correctly.
  • Error: Connection refused when accessing via web browser: Ensure that pgAdmin is running by checking its service status or restarting it with sudo systemctl restart apache2.
  • Error: Authentication failed: Verify that you are using the correct username and password created during setup.

Congratulations! You have successfully installed pgAdmin. Thanks for using this tutorial to install pgAdmin on Ubuntu 24.04 LTS. For additional help or useful information, we recommend you check the official pgAdmin website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button