How to install and use pgAdmin on an Ubuntu cloud server?

18-02-2024 02:29:31

pgAdmin is an open-source software for managing PostgreSQL databases. It features a graphical interface, SQL query tools, code debugger, and other utilities. This guide is based on an Ubuntu 20.04 cloud server and details the installation and usage of phpMyAdmin.

Installing pgAdmin

Start by installing the necessary dependencies for pgAdmin.

$ sudo apt-get install curl gnupg2 -y

Import the signature key for the pgAdmin software repository.

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

Add the pgAdmin software repository.

$ 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-get update --allow-insecure-repositories'

Install pgAdmin.

$ sudo apt install pgadmin4-web -y

Set up the web interface by entering an email address and login password.

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

Access the pgAdmin management address, for example: http://192.0.2.48/pgadmin4, and log in using the email address and password provided earlier.

Managing Databases

Log in to the pgAdmin management address, go to the Dashboard interface, and click on "Add New Server."

In the pop-up dialog box, enter the server's name in the "Name" field.

Switch to the "Connection" tab in the pop-up dialog box and enter the database connection information:

  • Host name/address: IP address
  • Port: Port number (enter 5432)
  • Maintenance database: Enter the database name
  • Username: Enter the database username
  • Password: Enter the database password

Click "Save" to save and log in to pgAdmin.

Upon successful login, you will see the previously connected server in the left panel of the dashboard. Expand the arrow, click on the database name.

By following these steps, pgAdmin has been successfully installed on your Ubuntu 20.04 cloud server.