How to install pgadmin in ubuntu 22. 04?

How to Install pgAdmin in Ubuntu 22.04?

pgAdmin is the widely used and most popular GUI-based management Tool for PostgreSQL. “pgAdmin” is an advanced open-source tool that offers a better Graphical User Interface, and a simplified schema, and it also simplifies the use and creation of Database Objects. “pgAdmin” interacts with the PostgreSQL determined to Develop, Test and Maintain Databases.

This article explains how you can install “pgAdmin” in Ubuntu 22.04.

How to Install pgAdmin in Ubuntu 22.04?

pgAdmin is Installed from the pgAdmin Repository. While installing pgAdmin, you can either install both the web mode and desktop mode together, which the “apt install pgadmin4” command does by default, or you can install pgAdmin Web Mode and pgAdmin Desktop Mode individually as well. Below are the steps that demonstrate how you can install pgAdmin in your Ubuntu System.

Step
Sponsored
1: Update Packages

Before installing “pgAdmin”, update the existing Ubuntu Repository to look for any packages that require upgrades. Use the “apt update” command with sudo privileges:

sudo apt update

Enter the sudo user password to look for updates in the packages:

How to install pgadmin in ubuntu 22. 04? 1

Once the Terminal completes updating, upgrade your Ubuntu Repository now with the “upgrade” command. Use the “apt upgrade” command with sudo privileges to upgrade any packages that require to be upgraded to the latest version:

sudo apt upgrade

Enter “Y” during the upgradation to continue the process:

How to install pgadmin in ubuntu 22. 04? 2

Step 2: Install “curl”

Once the existing packages are updated, install “curl” before you download “pgAdmin”. The “curl” command downloads any packages from a server. With curl, not only can you Download packages, but you can also use it to transfer data to a server and retrieve data from a server. In most Ubuntu Systems, curl is pre-installed. If your system is missing curl, use the “apt install” command to install curl:

sudo apt install curl

In our case, it was already installed:

How to install pgadmin in ubuntu 22. 04? 3

Step 3: Download “pgAdmin”

Now once “curl” is installed, Open any Web Browser to download “pgAdmin”. In our case, we opened the Firefox Browser:

How to install pgadmin in ubuntu 22. 04? 4

“pgAdmin” should be downloaded from the official “pgAdmin” Website. Either search for the “pgAdmin” website or Download pgAdmin directly by visiting the web page.

How to install pgadmin in ubuntu 22. 04? 5

On the official web page of “pgAdmin”, click on the Download option in the Navigation Bar:

How to install pgadmin in ubuntu 22. 04? 6

The Download page will appear which will consist of Operating System Options for “pgAdmin” packages. As you are using Ubuntu, click on the “APT” option for the “pgAdmin 4”:

How to install pgadmin in ubuntu 22. 04? 7

The various Ubuntu Versions that are available for the pgAdmin APT Repository will be listed. Choose the APT repository for Ubuntu 22.04 Version:

How to install pgadmin in ubuntu 22. 04? 8

Scroll Down and you will see the “pgAdmin” repository setup commands for Ubuntu:

How to install pgadmin in ubuntu 22. 04? 9

Download the Public Key for the “pgAdmin” Repository using the “curl” command:

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

The cursor moves to the next line in the Terminal indicating the Public Key was added:

How to install pgadmin in ubuntu 22. 04? 10

Now, Set up the Repository for the “pgAdmin” Configuration File using the 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’

The repository will be added to the Configuration File:

How to install pgadmin in ubuntu 22. 04? 11

Step 4: Install “pgAdmin”

Once the Public Key and the Packages are added to the Configuration File, install “pgAdmin” with the “apt install” command:

sudo apt install pgadmin4

The Terminal will start installing the packages, and wait for the installation process to complete:

How to install pgadmin in ubuntu 22. 04? 12

Step 5: Configure Web Interface

After the packages are added and “pgAdmin” is installed, you have to configure the “pgAdmin” interface to start working with it. The first step in the configuration includes setting up the “pgAdmin 4” for web mode and then configuring the “pgAdmin” user account. Run the “setup-web.sh” script which will set up the pgAdmin 4 in Web Mode with the “sudo” command:

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

Once the Web Mode Configuration for “pgAdmin” is completed, the Terminal will ask for the initial “pgAdmin” user account details:

How to install pgadmin in ubuntu 22. 04? 13

Enter the email and password for the initial “pgAdmin 4” user:

How to install pgadmin in ubuntu 22. 04? 14

Once you Retype the password and hit “Enter”, the “pgAdmin” application will ask for the Apache Web Server configuration and mount the “pgAdmin 4” at “/pgadmin4”:

How to install pgadmin in ubuntu 22. 04? 15

Enter “y” to continue configuring Apache Server and mounting the pgAdmin Application. As soon as the Apache Server is Configured, it will ask for the Server Restart. Enter “y” again to complete the pgAdmin installation. After the Apache Server restarts, the Terminal will show the local host URL where you can use the “pgAdmin 4” Application:

How to install pgadmin in ubuntu 22. 04? 16

Starting pgAdmin in Web Mode

You can use the pgAdmin application once it is initialized. Once you’ve installed and configured pgAdmin, the Terminal displays the local host link which can be used in the URL of a browser to access pgAdmin. Usually, the pgAdmin Web Application runs on the “127.0.0.1/pgadmin4” URL:

How to install pgadmin in ubuntu 22. 04? 17

Clicking on the URL will redirect you to the Web page on the Default Web Browser and open the pgAdmin Web Page:

How to install pgadmin in ubuntu 22. 04? 18

In the Email and Password Input boxes, enter the email and password of the user that you created while configuring the pgAdmin Web Mode in the Terminal:

See also  Design and Web team summary – 14 January 2022

How to install pgadmin in ubuntu 22. 04? 19

Once the email and password are entered, click on the Login button to access the pgAdmin Account:

How to install pgadmin in ubuntu 22. 04? 20

Wait for the pgAdmin User Page to load:

How to install pgadmin in ubuntu 22. 04? 21

Sponsored

The pgAdmin User Account Dashboard will open where you can Add a New Server, Configure Your Account, and do much more:

How to install pgadmin in ubuntu 22. 04? 22

This is one way of starting the pgAdmin Application through Web Mode.

Starting pgAdmin in Desktop Mode

The pgAdmin Application can also be used as an Ubuntu Application on the Desktop instead of using the Web browser and then accessing the pgAdmin through the URL. While installing the pgAdmin Application through the Repository, both the Desktop and the Web Mode for the pgAdmin Application are installed.

If the pgAdmin Desktop Mode is not installed on your Ubuntu System, use the “apt install” command to install pgAdmin:

sudo apt install pgadmin4-desktop

The “pgAdmin4-desktop” command only installs the Desktop Version of pgAdmin. Once installed, open the Applications Menu from your Ubuntu Home Screen:

In the Applications Menu, click on the Search Bar to type the Application you want to search:

How to install pgadmin in ubuntu 22. 04? 23

As we want to open pgAdmin, type pgAdmin in the Search Box. The pgAdmin Application icon will appear. Click on the application icon to start the application:

How to install pgadmin in ubuntu 22. 04? 24

Wait for the application to initialize:

How to install pgadmin in ubuntu 22. 04? 25

Once the pgAdmin Application starts, you will see the pgAdmin Home Screen where you can add a New Server and make changes to your pgAdmin account as well:

How to install pgadmin in ubuntu 22. 04? 26

Registering a Server in “pgAdmin”

A new Server can be added to the pgAdmin Application. To Register a New Server, right-click on the Servers option in the left panel of the Application:

How to install pgadmin in ubuntu 22. 04? 27

A drop-down menu will appear where you can register, create, refresh, and remove server groups. Click on the Register to expand it. In the additional expanded Register Option, click on the “Server” to Register your own Server:

How to install pgadmin in ubuntu 22. 04? 28

The Server Registration Menu will appear:

How to install pgadmin in ubuntu 22. 04? 29

Enter the Name of your Server in the “Name” Field:

How to install pgadmin in ubuntu 22. 04? 30

In our case, we added the name “localhost”. Once you have added the name click on the Connection option from the Menu Options:

How to install pgadmin in ubuntu 22. 04? 31

Now in the Connection Menu, the Port, maintenance Database, and username are pre-added. Add the Host Name only if you want to continue with the custom default settings:

How to install pgadmin in ubuntu 22. 04? 32

Once the Hostname, username, and password are added for the new Server, click on the “Save” button:

How to install pgadmin in ubuntu 22. 04? 33

The connections will be made successfully. If the connection fails, you have to set a password for your Postgres account as during the Creation of the Postgres Account, the password is not required:

How to install pgadmin in ubuntu 22. 04? 34

To set the password for the User, Switch to the Postgres User with the command:

sudo -i -u <userName>

In our case, the user name is “darren”. Thus, to switch to the “darren” Postgres User, the “sudo” command will be:

sudo -i -u darren

This will change the Command line to the Postgres Account for darren:

How to install pgadmin in ubuntu 22. 04? 35

Now, you have to Access the PostgreSQL Prompt with the following command:

psql

Once you have accessed the User PostgreSQL Prompt, you can run commands and queries. The “=#” indicates the PostgreSQL Prompt is currently being used:

How to install pgadmin in ubuntu 22. 04? 36

You can now set the password for the Postgres User with the command “password” followed by the username of the User:

password <<strong>userNamestrong>>

In our case, the user is “darren”. Thus to set the password for “darren”, the command will be:

password darren

The Command Line will ask you to Enter the New Password and then Retype the Password for confirmation:

How to install pgadmin in ubuntu 22. 04? 37

Once the Password is set for the User “darren”, open the pgAdmin Connection Menu again and retype the new password. Click on the “Save” button as soon as you are done with the configuration:

How to install pgadmin in ubuntu 22. 04? 38

After the connection is set, you will see the server activity on the pgAdmin Dashboard:

How to install pgadmin in ubuntu 22. 04? 39

Moreover, you can expand the Servers and look for the “localhost” server that you created earlier:

How to install pgadmin in ubuntu 22. 04? 40

Expanding the “localhost” server will list the options for Databases, Tablespaces, and User Roles:

How to install pgadmin in ubuntu 22. 04? 41

At this point, you are all set to use pgAdmin to perform any specific Postgres tasks.

Conclusion

pgAdmin can be installed with the “apt install pgadmin4” command, but before the installation, the Public Key should be added and the configuration file for the pgAdmin Repository should be set up. Once pgAdmin is installed, we can either use the Web Mode or the Desktop Mode. Each step is discussed in detail in this article.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply