pgAdmin is an open-source feature-rich, frontend management tool that allows you to easily administer and manage your PostgreSQL relational database from a web browser.
It provides an easy-to-use user interface that simplifies the creation and monitoring of databases and database objects. PgAdmin 4 is an improvement of the earlier pgAdmin tool and is available for Linux, Windows, macOS systems, and even a Docker container.
In this tutorial, you will learn how to install PostgreSQL with pgAdmin4 on Linux Mint 21 and Linux Mint 20.
Step 1: Install PostgreSQL Database on Linux Mint
1. To start off, launch your terminal and update your packages using the apt package manager as shown.
$ sudo apt update -y
Once the update is complete, proceed to the next step.
Since pgAdmin4 provides a frontend interface for the management of PostgreSQL database objects, it’s essential to have PostgreSQL installed first.
2. To do this, we are going to install the postgresql package and postgresql-contrib which offers extended features that extend the functionality of PostgreSQL.
$ sudo apt install postgresql postgresql-contrib

3. Usually, PostgreSQL starts automatically on boot up. You can confirm this using the command given below:
$ sudo systemctl status postgresql

4. To log in to your PostgreSQL instance, first switch to the postgres user. The Postgres user comes included by default with the installation of PostgreSQL. Then run the psql command as shown.
$ sudo -i -u postgres $ psql # \q

5. Additionally, you can check if the database server is accepting incoming connections as shown.
$ sudo pg_isready

Step 2: Install pgAdmin4 on Linux Mint
pgAdmin4 is available for Ubuntu 16.04 and later versions and can easily be installed using the APT package manager. The same cannot support Linux Mint and Pgadmi4 developers are yet to include support that allows users to easily install the frontend management tool using the APT package manager.
6. The only viable option is to install pgAdmin4 from a virtual environment. So first, we will install the prerequisite packages as shown.
$ sudo apt install libgmp3-dev build-essential libssl-dev

7. Next, install the Python virtual environment and associated dependencies.
$ sudo apt install python3-virtualenv python3-dev libpq-dev

8. Next, create a directory where you will create a virtual environment.
$ mkdir pgadmin4 && cd pgadmin4
9. Then create the virtual environment as shown. Here, pgadmin4env is the name of the virtual environment.
$ virtualenv pgadmin4env

10. Once the virtual environment is in place, activate it as shown.
$ source pgadmin4env/bin/activate
11. Then use the pip tool to install pgadmin4 as shown.
$ pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v6.15/pip/pgadmin4-6.15-py3-none-any.whl

12. Next, create a configuration file config_local.py.
-------- On Linux Mint 20 -------- $ sudo nano pgadmin4env/lib/python3.8/site-packages/pgadmin4/config_local.py -------- On Linux Mint 21 -------- $ sudo nano pgadmin4env/lib/python3.10/site-packages/pgadmin4/config_local.py
and add the lines below.
import os DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.pgadmin/')) LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log') SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db') SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions') STORAGE_DIR = os.path.join(DATA_DIR, 'storage') SERVER_MODE = False AZURE_CREDENTIAL_CACHE_DIR = os.path.join(DATA_DIR, 'azurecredentialcache')

13. To start the pgAdmin4 management tool, invoke the command:
-------- On Linux Mint 20 -------- $ python pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgAdmin4.py -------- On Linux Mint 21 -------- $ python pgadmin4env/lib/python3.10/site-packages/pgadmin4/pgAdmin4.py

14. Finally, head over to your browser and browse the address shown.
http://127.0.0.1:5050
You will be prompted to set the master password, so proceed and set a strong password and click the ‘Ok’ button.

15. To make things easier, you can create an alias in the ~/.bashrc file as shown.
-------- On Linux Mint 20 -------- $ echo "alias startPg='~/pgadmin4/pgadmin4env/bin/python pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgAdmin4.py'" >> ~/.bashrc -------- On Linux Mint 21 -------- $ echo "alias startPg='~/pgadmin4/pgadmin4env/bin/python pgadmin4env/lib/python3.10/site-packages/pgadmin4/pgAdmin4.py'" >> ~/.bashrc
16. Next, update the bashrc file.
$ source ~/.bashrc
17. Finally, you can start the pgAdmin4 management tool by simply invoking the startPg command.
$ startPg &

Once again head over to your browser and log in to the PgAdmin4 interface. And this concludes the installation of PostgreSQL with pgAdmin4 on Linux Mint 21 and Linux Mint 20.



I am getting the below error while installing pgadmin4 in Linux Mint.
aceback (most recent call last):File "pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgAdmin4.py", line 35, in
import config
File "/home/carlos/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/config.py", line 25, in
from pgadmin.utils import env, IS_WIN, fs_short_path
File "/home/carlos/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/__init__.py", line 21, in
from flask import Flask, abort, request, current_app, session, url_for
File "/home/carlos/pgadmin4/pgadmin4env/lib/python3.8/site-packages/flask/__init__.py", line 19, in
from jinja2 import Markup, escape
ImportError: cannot import name 'Markup' from 'jinja2' (/home/carlos/pgadmin4/pgadmin4env/lib/python3.8/site-packages/jinja2/__init__.py)
@Carlos,
I have updated the pgadmin4 installation instructions for Linux Mint 21 and Linux Mint 20. I hope it will fix your pgadmin4 installation errors…
As suggested by @Thomas Tschoepke, there’s an easier way: adding the sources to your APT. Linux Mint follows Ubuntu 20, which in turn is based on Debian “bullseye”, so Thomas’s instructions just need to be adjusted:
HTH
Tried this approach on Linux Mint 20.3 Una (base: Ubuntu 20.04 focal), the installation ran without problems, but starting pgAdmin4 failed with the message “The pgadmin 4 server could not be contacted”.
Reason in my case:
the symbolic python-links under /usr/pgadmin4/venv/bin/were dead because of missing python3.9
Workaround:
This tutorial does not work anymore… Back to version 3 :-(
$ sudo curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add
$ sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
$ sudo apt update
$ sudo apt install pgadmin4-desktop #for desktop
OR
$ sudo apt install pgadmin4-web #for web
If web version:
With these steps I get:
E: The repository 'https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 Release' does not have a Release file.E: The repository 'http://apt.postgresql.org/pub/repos/apt ulyssa-pgdg Release' does not have a Release file.
Hi Ami,
If you’re using Linux Mint 20, you just need to change the line:
with
in the file “/etc/apt/sources.list.d/pgadmin4.list”
Then continue with the step “sudo apt update”, and so on.
HTH
@Thomas,
I have tried it on my Linux Mint 20, and it worked well. What error are you getting on your side?
Can’t remember the error. But with the steps, I posted above one does not need virtual environments and stuff…
The install is straight forward as any other package.
pgadmin4env) [email protected]:~/pgadmin4# python pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgAdmin4.py
NOTE: Configuring authentication for DESKTOP mode.
Traceback (most recent call last):
File “/root/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/base.py”, line 1771, in _execute_context
self.dialect.do_execute(
File “/root/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/default.py”, line 717, in do_execute
cursor.execute(statement, parameters)
sqlite3.OperationalError: table version already exists
Got the same issue, does anyone know how to uninstall all of this?
Same issue
Same issue for me too
Step 11: The package is no longer available, currently you can use Version 4.30:
pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.30/pip/pgadmin4-4.30-py3-none-any.whl
Step 13: Meanwhile in Version 4.30 there is a binary to start the server:
./pgadmin4env/bin/pgadmin4&
@Sven,
Thanks, corrected in the article as suggested by you…
Can I ask that want version of python you used, because I got error like this:
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "./pgadmin4env/bin/pgadmin4", line 5, in from pgadmin4.pgAdmin4 import main File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgAdmin4.py", line 94, in app = create_app() File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/__init__.py", line 351, in create_app db_upgrade(app) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/db_upgrade.py", line 25, in db_upgrade flask_migrate.upgrade(migration_folder) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/flask_migrate/__init__.py", line 95, in wrapped f(*args, **kwargs) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/flask_migrate/__init__.py", line 280, in upgrade command.upgrade(config, revision, sql=sql, tag=tag) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/command.py", line 294, in upgrade script.run_env() File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/script/base.py", line 490, in run_env util.load_python_file(self.dir, "env.py") File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/util/pyfiles.py", line 97, in load_python_file module = load_module_py(module_id, path) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/util/compat.py", line 182, in load_module_py spec.loader.exec_module(module) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/../../migrations/env.py", line 93, in run_migrations_online() File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/../../migrations/env.py", line 86, in run_migrations_online context.run_migrations() File "", line 8, in run_migrations File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/runtime/environment.py", line 813, in run_migrations self.get_context().run_migrations(**kw) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/runtime/migration.py", line 560, in run_migrations step.migration_fn(**kw) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/migrations/versions/fdc58d9bd449_.py", line 45, in upgrade op.create_table('version', File "", line 8, in create_table File "", line 3, in create_table File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/operations/ops.py", line 1109, in create_table return operations.invoke(op) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/operations/base.py", line 354, in invoke return fn(self, operation) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/operations/toimpl.py", line 101, in create_table operations.impl.create_table(table) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/ddl/impl.py", line 277, in create_table self._exec(schema.CreateTable(table)) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/ddl/impl.py", line 146, in _exec return conn.execute(construct, multiparams) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1200, in execute return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS) File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/sql/ddl.py", line 77, in _execute_on_connection return connection._execute_ddl( File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1290, in _execute_ddl ret = self._execute_context( File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1748, in _execute_context self._handle_dbapi_exception( File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1929, in _handle_dbapi_exception util.raise_( File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 211, in raise_ raise exception File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1705, in _execute_context self.dialect.do_execute( File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 691, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) table version already exists [SQL: CREATE TABLE version ( name VARCHAR(32) NOT NULL, value INTEGER NOT NULL, PRIMARY KEY (name) ) ] (Background on this error at: http://sqlalche.me/e/14/e3q8) ^C [1]+ Exit 1 ./pgadmin4env/bin/pgadmin4Hi LJ,
Got the same error as yours…
Tried to fix it by myself. But it didn’t worked.
My Linux Mint is 20.1 Ulyssa and the Python version is 3.8.5 (The default one available with the OS).
I was managed to install and connect Postgres with Ravi Saive’s guidelines (Author of this article).
But, I managed to connect PGAdmin3 (the version currently available in Mint’s Software Manager) with the Postgres server.
But with one change..
1) Login to Server as Super User –
sudo -u postgres psql postgres2) Reset the super user’s password using –
postgres=# ALTER USER postgres PASSWORD 'root';(https://stackoverflow.com/questions/7695962/postgresql-password-authentication-failed-for-user-postgres)
Please share if you find out a solution for PGAdmin4
I have the same issue…
Same issue for me too