How To Install pgAdmin 4 in Linux Mint
This guide shows how to install the latest version of pgAdmin 4 in Linux Mint, from the official APT repository.
What is pgAdmin?
pgAdmin is a popular and feature-rich open-source database administration and development environment for the PostgreSQL database management system. It is a powerful tool that can help you in your day-to-day database management activities with PostgreSQL. pgAdmin is powered by Python and React, using the Flask framework.
Key pgAdmin Features
- Multi-platform support,
- It supports multiple PostgreSQL versions,
- It comes with extensive documentation,
- It supports multiple deployment modes: desktop mode, using a purpose-built runtime and server mode, supporting multiple users over the web,
- It offers several database development and management tools, such as a powerful query tool with syntax highlighting, fast datagrid for display/entry of data, graphical query plan display, grant Wizard for rapid updates to ACLs, procedural language debugger (supporting pl/pgsql and edb-spl), schema diff tool for managing differences between schemas, and ERD tool for designing and documenting schemas,
- It allows you to create, view, and edit all common PostgreSQL objects, and
- It also comes with multibyte support.
Setup pgAdmin Repository on Linux Mint
The first step is to set up the APT repository for pgAdmin 4 on your computer as follows. This contains the pgAdmin packages. Start by installing the public key for the repository by running this command:
$curl -fsS https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo gpg --dearmor -o /usr/share/keyrings/packages-pgadmin-org.gpg
Next, create the repository configuration file like this:
$sudo vim /etc/apt/sources.list.d/pgadmin4.list
Copy and paste the following line into the file.
deb [signed-by=/usr/share/keyrings/packages-pgadmin-org.gpg] https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/<ubuntu_codename> pgadmin4 main
Note: By default, the above repository is intended for Ubuntu versions. Because every Linux Mint version is derived from or is based on a corresponding Ubuntu version, you need to set the correct Ubuntu version code name in the repository file.
To get your Linux Mint version description and code name, run this command:
$ lsb_release -dc
In this example, the Linux Mint codename is una, now get the corresponding codename for Ubuntu. You can find a list of all supported Linux Mint releases and code names and their corresponding Ubuntu package base (code name) on this page.
Your repository configuration should now look like this.
Next, update the local package index to include packages from the newly added pgAdmin repository, by running the following commands:
$sudo apt update
If the repository is set up correctly, you should be able to view information about the pgAdmin package by running the following command:
$apt show pgadmin4
Install pgAdmin 4 in Linux Mint
As I mentioned earlier, pgAdmin has two modes: desktop mode and web mode. To install for both desktop and web modes, run this command:
$sudo apt install pgadmin4
To only install the desktop mode, run this command:
$sudo apt install pgadmin4-desktop
To install for web mode only, issue this command:
$sudo apt install pgadmin4-web
Besides, to configure the webserver, if you installed pgadmin4-web, then run this command:
How To Connect to a Database using pgAdmin 4
After successfully installing pgAdmin, search for it in the system menu and open it. To connect to a database server, under Quick Links, click on Add New Server.
In the pop window, under the General tab, enter the connection Name as shown in the following screenshot.
Then click the Connection tab and enter the database name/IP address, port (default is 5432), database name (maintenance database), database username, and the user’s password. Then click Save.
If the database connection is successful, the new connection will appear under the list of servers. Click on the connection name to expand it. A list of all databases on the server will appear. Click on the database you intend to connect to and start using pgAdmin 4.
Congratulations! You have successfully installed pgAdmin 4 on your Linux Mint system. For more information, see the pgAdmin 4 website which includes the documentation. You can also ask any questions about this guide via the feedback form below.