Total Pageviews

4505

Installation of pgAdmin4 on Ubuntu 22.04|20.04|18.04



This page has been written primarily to guide new users on how to install pgAdmin 4 on Ubuntu 22.04|20.04|18.04 Linux system. pgAdmin is a feature-rich and open source PostgreSQL administration and development platform that runs on Linux, Unix, Mac OS X, and Windows.

With pgAdmin you can manage PostgreSQL database servers, from version 9.2 using an intuitive and powerful web interface.

The one requirement for installation of pgAdmin4 on Ubuntu 22.04/20.04/18.04 is PostgreSQL server. You can choose to go with any version of PostgreSQL server >=9.6. We have guides which can be used as reference while installing PostgreSQL database server.

Having completed installation of PostgreSQL database server on Ubuntu, proceed to install and initiate pgAdmin4 on the system.

Step 1: Add pgAdmin4 repository toUbuntu 22.04|20.04|18.04

The pgAdmin packages for all Debian based Linux operating systems are available from the pgAdmin APT repository. In this step we will add the repository to our Ubuntu system.

$ curl -fsSL https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/pgadmin.gpg


If get the error

    E: Package 'pgadmin4' has no installation candidate

    E: Unable to locate package pgadmin4-apache2


Here's how I solved the issue;

The issue arises because the repository for pgadmin has not been added to your local machine. To solve the issue, do the following below;


Note: This should work in Ubuntu 16.04 (Xenial), Ubuntu 18.04 (Bionic), Ubuntu 19.10 (Eoan), Ubuntu 20.04 (Focal), Debian 9 (Stretch) and Debian 10 (Buster)

Install the public key for the repository (if not done previously):

$ curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add


Create the repository configuration file:
$ sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'

Choose the Installation method that you want:
  • Install pgAdmin (for both desktop and web modes):

    $ sudo apt install pgadmin4
    
  • Install pgAdmin (for desktop mode only):

    $ sudo apt install pgadmin4-desktop
    
  • Install pgAdmin (for web mode only):

    $ sudo apt install pgadmin4-web 
    

You can configure the webserver, if you installed pgadmin for web mode:

$ sudo /usr/pgadmin4/bin/setup-web.sh
Open your browser and http://[ServerIP_or_domain]/pgadmin4.

Allow remote access

In this step, we will look at how to configure Postgres to accept external connections. To begin, open the configuration file with your preferred editor:
# nano /etc/postgresql/10/main/postgresql.conf

Look for this line in the file:

#listen_addresses = 'localhost'

Uncomment, and change the value to '*', this will allow Postgres connections from anyone.

listen_addresses = '*'

Save and exit the file. Next, modify pg_hba.conf to also allow connections from everyone. Open the file with your preferred editor:

# nano /etc/postgresql/10/main/pg_hba.conf

Modify this section:

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5

To this:

# IPv4 local connections:
host    all             all             0.0.0.0/0            md5

This file stores the client authentication, each record specifies an IP address range, database name, username, and authentication method. In our case, we are granting all database users access to all databases with any IP address range, thus, letting any IP address connect. Save and exit the file. Next, allow port 5432 through the firewall by executing:

# sudo ufw allow 5432/tcp

Finally, restart Postgres to apply all the changes you have made to its configuration by running:

$ sudo systemctl restart postgresql

Connect to Postgres remotely

In this step, you will be connecting to your server from an external machine. Connect to the remote Postgres database by running:

$ psql -h {server_ip} -d usersDB -U Sammy

Where {server_ip} is your server IP address, you will get a prompt to type your user password, if the credentials match you’ll be logged into the Postgres shell for cleopatra and database egypt.

Note: If you still cannot connect, you can reset your postgres user's password NOT linux default user 

$ sudo -u postgres psql postgres
postgress# \password postgres
Enter new password

Then use this new password to connect your pgAdmin4 using

  • postgres as Maintenance database

  • postgres as username

  • then new password

No comments:

Post a Comment

ORA-00845: MEMORY_TARGET not supported on this system

 The shared memory file system should have enough space to accommodate the MEMORY_TARGET and MEMORY_MAX_TARGET values. To verify: SQL> sh...