How to Install PostgreSQL with pgAdmin4 on Linux Mint 20

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 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
Install PostgreSQL on Linux Mint
Install PostgreSQL on Linux Mint

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

$ sudo systemctl status postgresql
Check PostgreSQL Status
Check PostgreSQL Status

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
Connect to PostgreSQL Shell
Connect to PostgreSQL Shell

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

$ sudo pg_isready
Check PostgreSQL Accepting Incoming Connections
Check PostgreSQL Accepting Incoming Connections

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 20 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
Install Prerequisite Packages
Install Prerequisite Packages

7. Next, install the Python virtual environment and associated dependencies.

$ sudo apt install python3-virtualenv python3-dev libpq-dev
Install Python Virtual Environment
Install Python Virtual Environment

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
Create Virtual Environment for pgAdmim4
Create Virtual Environment for pgAdmim4

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
Install PgAdmin4 in Linux Mint
Install PgAdmin4 in Linux Mint

12. Next, create a configuration file

$ sudo nano pgadmin4env/lib/python3.8/site-packages/pgadmin4/

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')
Create PgAdmin4 Configuration
Create PgAdmin4 Configuration

13. To start the pgAdmin4 management tool, invoke the command:

$ python pgadmin4env/lib/python3.8/site-packages/pgadmin4/
Start PgAdmin4 Service
Start PgAdmin4 Service

14. Finally, head over to your browser and browse the address shown.

You will be prompted to set the master password, so proceed and set a strong password and click the ‘Ok’ button.

Set PgAdmin4 Password
Set PgAdmin4 Password

15. To make things easier, you can create an alias in the ~/.bashrc file as shown.

$ echo "alias startPg='~/pgAdmin4/venv/bin/python ~/pgAdmin4/venv/lib/python3.8/site-packages/pgadmin4/'" >> ~/.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
Start PgAdmin4 Tool
Start PgAdmin4 Tool

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

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

14 thoughts on “How to Install PostgreSQL with pgAdmin4 on Linux Mint 20”

    • $ sudo curl | sudo apt-key add
      $ sudo sh -c 'echo "deb pgadmin4 main" > /etc/apt/sources.list.d/pgadmin4.list && apt update'
      $ sudo apt update
      $ sudo apt install pgadmin4-desktop #for desktop
      $ sudo apt install pgadmin4-web #for web

      If web version:

      $ sudo /usr/pgadmin4/bin/
      • 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.

  1. pgadmin4env) [email protected]:~/pgadmin4# python pgadmin4env/lib/python3.8/site-packages/pgadmin4/
    NOTE: Configuring authentication for DESKTOP mode.
    Traceback (most recent call last):
    File “/root/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/”, line 1771, in _execute_context
    File “/root/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/”, line 717, in do_execute
    cursor.execute(statement, parameters)
    sqlite3.OperationalError: table version already exists

      • Can I ask that want version of python you used, because I got error like this:

        (pgadmin4env) [email protected]:~/pgadmin4$ ./pgadmin4env/bin/pgadmin4&
        [1] 38587
        (pgadmin4env) [email protected]:~/pgadmin4$ NOTE: Configuring authentication for DESKTOP mode.
        Traceback (most recent call last):
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", 
        line 1705, in _execute_context
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", 
        line 691, in do_execute
            cursor.execute(statement, parameters)
        sqlite3.OperationalError: table version already exists

        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/", line 94, in 
            app = create_app()
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/", line 351, in create_app
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/", line 25, in db_upgrade
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/flask_migrate/", line 95, in wrapped
            f(*args, **kwargs)
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/flask_migrate/", line 280, in upgrade
            command.upgrade(config, revision, sql=sql, tag=tag)
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/", line 294, in upgrade
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/script/", line 490, in run_env
            util.load_python_file(self.dir, "")
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/util/", 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/", line 182, in load_module_py
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/../../migrations/", line 93, in 
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/pgadmin/setup/../../migrations/", line 86, in run_migrations_online
          File "", line 8, in run_migrations
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/runtime/", line 813, in run_migrations
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/runtime/", line 560, in run_migrations
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/pgadmin4/migrations/versions/", line 45, in upgrade
          File "", line 8, in create_table
          File "", line 3, in create_table
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/operations/", line 1109, in create_table
            return operations.invoke(op)
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/operations/", line 354, in invoke
            return fn(self, operation)
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/operations/", line 101, in create_table
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/ddl/", line 277, in create_table
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/alembic/ddl/", line 146, in _exec
            return conn.execute(construct, multiparams)
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", line 1200, in execute
            return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/sql/", line 77, in _execute_on_connection
            return connection._execute_ddl(
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", line 1290, in _execute_ddl
            ret = self._execute_context(
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", line 1748, in _execute_context
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", line 1929, in _handle_dbapi_exception
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/util/", line 211, in raise_
            raise exception
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", line 1705, in _execute_context
          File "/home/lj/pgadmin4/pgadmin4env/lib/python3.8/site-packages/sqlalchemy/engine/", line 691, in do_execute
            cursor.execute(statement, parameters)
        sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) table version already exists
        CREATE TABLE version (
        	name VARCHAR(32) NOT NULL, 
        	value INTEGER NOT NULL, 
        	PRIMARY KEY (name)
        (Background on this error at:
        [1]+  Exit 1                  ./pgadmin4env/bin/pgadmin4

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.