How to Install pgAdmin on Ubuntu 22.04

In this post, we will show you how to Install pgAdmin on Ubuntu 22.04 and will also cover how to connect to existing PostgreSQL database server.

pgAdmin is a graphical user interface for PostgreSQL administration, it allows admin to manage postgresql databases efficiently. With an active community of users and developers, pgAdmin receives regular updates and bug fixes, ensuring a reliable database management experience.

Prerequisites

  •  Pre-Install Ubuntu 22.04
  • Sudo User with admin access
  • Internet Access
  • Pre-Install PostgreSQL

Without any delay, lets quickly jump into pgadmin installation steps on Ubuntu 22.04

1) Install Curl Utility

We need curl command line utility to install public keys of package repository. So, open the terminal and run below apt command,

$ sudo apt update && sudo apt install curl -y

Install-curl-apt-command-ubuntu

2) Configure pgAdmin APT Package Repository

In order to configure pgadmin repository, first install its public key using below curl command.

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

Now create the repository configuration file using beneath 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'

Pgadmin-APT-Repository-Ubuntu-22-04

3) Install pgAdmin on Ubuntu 22.04

Once you are done with setup of pgAdmin repository then run following apt command to install pgAdmin for both desktop and web modes.

$ sudo apt install pgadmin4 -y

Install pgAdmin on Ubuntu 22.04

4) Configure User Account for pgAdmin Web Interface

Whenever we install pgadmin4 package then it also installs a script “/usr/pgadmin4/bin/setup-web.sh” which is used to configure user account for web interface. Using this script, user accounts will be secured and disallow unauthorized access.

Run the script from the terminal.

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

Configure-pgAdmin-Web-Interface-Users-Ubuntu

Script will prompt you to enter email address, password and restart Apache service.

5) Access pgAdmin Web Interface

With the setup complete, you can now access pgAdmin through your web browser. Open your preferred web browser and enter the following URL in the address bar:

http://<IP-Address-of-Your-System>/pgadmin4

You will be prompted to log in using the email address and password you provided during the setup process.

PgAdmin4-Login-Page-Ubuntu-22-04

Upon successful login, you will gain access to the PGAdmin interface, where you can start managing your PostgreSQL databases with ease.

pgAdmin-Graphical-User-Interface-Ubuntu-22-04

6) Connect to PostgreSQL From pgAdmin

Now that you’re logged in to pgAdmin, it’s time to connect it to your PostgreSQL database server. Follow these steps:

a ) Right Click on Servers Icon, choose Register and then server as shown below:

Register-PostgreSQL-Database-pgAdmin-Ubuntu

b) Fill in the following details in General and Connection tab

  • Registered Server Name
  • Hostname/address: Enter the IP address or hostname of your PostgreSQL server.
  • Port: By default, PostgreSQL listens on port 5432.
  • Maintenance database: Enter the name of the default database you want to connect to.
  • Username: Enter the username of your PostgreSQL user with appropriate privileges.
  • Password: Enter the password associated with the username.

Server-Registration-Name-pgAdmin-Interface

PostgreSQL-Connection-Details-pgAdmin-GUI-Ubuntu-22-04

Click “Save” to register the server to pgAdmin.

Once the server is added, you can expand it in the pgAdmin dashboard to access the databases, schemas, tables, and other objects within your PostgreSQL server. You can perform various administrative tasks, execute queries, and manage your databases efficiently using pgAdmin’s intuitive interface.

pgAdmin-Interface-After-Connecting-PostgreSQL-Server

That’s all from this post, I hope above mentioned steps were informative and useful. Feel free to post your queries and feedback in below comments section.

2 thoughts on “How to Install pgAdmin on Ubuntu 22.04”

  1. Need Help

    As a prerequisite, I installed PostgreSQL, using your instructions.

    I then followed your instructions to install pgAdmin.
    When I execute Step 3 “sudo apt install pgadmin4 -y”, the output says “Package ‘pgadmin4’ has no installation candidate”

    Can you help me fix this please.
    I placed all of the steps and output below:

    Thanks,
    Robert

    rbrown@HiveMQ:~$ sudo apt update && sudo apt install curl -y
    Hit:1 https://dl.google.com/linux/chrome/deb stable InRelease
    Hit:2 http://security.ubuntu.com/ubuntu noble-security InRelease
    Hit:3 http://us.archive.ubuntu.com/ubuntu noble InRelease
    Hit:4 http://us.archive.ubuntu.com/ubuntu noble-updates InRelease
    Hit:5 http://apt.postgresql.org/pub/repos/apt noble-pgdg InRelease
    Hit:6 http://us.archive.ubuntu.com/ubuntu noble-backports InRelease
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    All packages are up to date.
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    The following NEW packages will be installed:
    curl
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 227 kB of archives.
    After this operation, 532 kB of additional disk space w
    ill be used.
    Get:1 http://us.archive.ubuntu.com/ubuntu noble-updates/main amd64 curl amd64 8.5.0-2ubuntu10.1 [227 kB]
    Fetched 227 kB in 1s (383 kB/s)
    Selecting previously unselected package curl.
    (Reading database ... 151349 files and directories currently installed.)
    Preparing to unpack .../curl_8.5.0-2ubuntu10.1_amd64.deb ...
    Unpacking curl (8.5.0-2ubuntu10.1) ...
    Setting up curl (8.5.0-2ubuntu10.1) ...
    Processing triggers for man-db (2.12.0-4build2) ...
    rbrown@HiveMQ:~$ curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg
    rbrown@HiveMQ:~$ 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'
    Hit:1 http://us.archive.ubuntu.com/ubuntu noble InRelease
    Hit:2 http://us.archive.ubuntu.com/ubuntu noble-updates InRelease
    Hit:3 https://dl.google.com/linux/chrome/deb stable InRelease
    Hit:4 http://us.archive.ubuntu.com/ubuntu noble-backports InRelease
    Hit:5 http://security.ubuntu.com/ubuntu noble-security InRelease
    Hit:6 http://apt.postgresql.org/pub/repos/apt noble-pgdg InRelease
    Get:7 https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/noble pgadmin4 InRelease [4,217 B]
    Fetched 4,217 B in 1s (2,865 B/s)
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    All packages are up to date.
    rbrown@HiveMQ:~$ sudo apt install pgadmin4 -y
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    Package pgadmin4 is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source

    E: Package 'pgadmin4' has no installation candidate

    1. Pradeep Kumar

      Hi Robert,

      As I can see you are trying to install pgadmin4 on Ubuntu 24.04 but it is not yet supported by Ubuntu 24.04 that’s why you are getting above error.

      We are expecting that it will be supported by June but till that time you can follow the below workaround.

      1) Use mantic instead of noble
      2) Make sure python3.11 is installed.

      $ sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/mantic pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
      $ sudo apt install pgadmin4
      $ sudo add-apt-repository ppa:deadsnakes/ppa
      $sudo apt update
      $ sudo apt install python3.11

Leave a Comment

Your email address will not be published. Required fields are marked *