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/v8.11/pip/pgadmin4-8.11-py3-none-any.whl
12. Next, create a configuration file config_local.py.
-------- On Linux Mint 22/21 -------- $ sudo nano pgadmin4env/lib/python3.10/site-packages/pgadmin4/config_local.py -------- On Linux Mint 20 -------- $ sudo nano pgadmin4env/lib/python3.8/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 22/21 -------- $ python pgadmin4env/lib/python3.10/site-packages/pgadmin4/pgAdmin4.py -------- On Linux Mint 20 -------- $ python pgadmin4env/lib/python3.8/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 22/21 -------- $ echo "alias startPg='~/pgadmin4/pgadmin4env/bin/python pgadmin4env/lib/python3.10/site-packages/pgadmin4/pgAdmin4.py'" >> ~/.bashrc -------- On Linux Mint 20 -------- $ echo "alias startPg='~/pgadmin4/pgadmin4env/bin/python pgadmin4env/lib/python3.8/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.
Please restart your machine and let me know if it’s sufficient to access
http://127.0.0.1:5050/browser
.Your instructions do not work:
pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v7.5/pip/pgadmin4-7.5-py3-none-any.whl
Collecting pgadmin4==7.5
———————————- output ——————-
ERROR: HTTP error 404 while getting https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v7.5/pip/pgadmin4-7.5-py3-none-any.whl
ERROR: Could not install requirement pgadmin4==7.5 from https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v7.5/pip/pgadmin4-7.5-py3-none-any.whl because of HTTP error 404 Client Error: Not Found for url: https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v7.5/pip/pgadmin4-7.5-py3-none-any.whl for URL https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v7.5/pip/pgadmin4-7.5-py3-none-any.whl
@Kristy,
I’ve updated the link. Please use the correct link to download the latest
.whl
file for installation.Hello guys!
Sorry, but I tried everything and didn’t figure out the issue in Mint 22.
When I try to push the final run into installing pgAdmin4, I get an error due to incompatibility with my Python version.
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
pgadmin4-server : Depends: python3.8 but it is not installable”
Thats my python version(came in mint22 already):
“Python 3.12.3 (main, Jul 31 2024, 17:43:48) [GCC 13.2.0]”
Linux Mint 22 Cinnamon – v.6.2.7
@Erick,
Since pgAdmin4 is specifically looking for Python 3.8, you need to install this version alongside your existing Python 3.12.3. You can have multiple Python versions installed on the same system.
Thank you for this awesome tutorial. Installed pgadmin on Mint 22 wilma. It was needed to change some versions numbers, but eventually it works!!!
Hey,
Great article! It actually worked like a charm.
My only question is how to register a server to do something in pgAdmin? For test and learning purposes only, I do not actually have a server. Is there a way to use my laptop for this?
Thanks a lot.
@Bart,
To register a server in pgAdmin, do following:
1. Open pgAdmin and go to “Servers” in the left pane and right-click on “Servers” and choose “Create” > “Server“.
2. In the “Create – Server” dialog, enter a name for your server and go to the “Connection” tab and enter localhost as the host, and the username (postgres) and password you set earlier.
3. Click “Save” to register the server. If everything is set up correctly, you should be able to connect to your locally installed PostgreSQL server.
Thank you very much. It works fine on my Linux Mint 21. But every time I quit and want to start again I have to go through the following steps to make it start again:
Otherwise, I get the following error when I run startPg:
/home/developer/pgadmin4/pgadmin4env/bin/python: can't open file '/home/developer/pgadmin4env/lib/python3.10/site-packages/pgadmin4/pgAdmin4.py': [Errno 2] No such file or directory
Or when I just try to start pgadmin4.py:
@Developer,
To simplify the process, you can create a shell script to automate these steps.
Make sure to replace /path/to/your/pgadmin4 with the actual path to your pgAdmin4 installation.
Now make the script executable and start pgAdmin4 by simply running:
It looks like your system is suggesting to use python3 instead of python to run the script.
This should resolve the “Command ‘python’ not found” error. Let me know if you encounter any further issues!
Hi Ravi,
I tried your suggestion on creating a shell script, however I’m not getting anything in return when I run it using
chmod +x start_pgadmin4.sh
and./start_pgadmin4.sh
, it doesn’t start pgadmin tool nor triggers any error in the terminal.Regards
Hi,
The latest #11 as today is:
and you can check the latest one from this link:
https://apt.postgresql.org/pub/pgadmin/pgadmin4/
Hi, Thanks for the tutorial.
I am fine with step 12
If I take the mint 20 option nano says :
If I take the mint 21 option terminal says:
at which point I remember I am using your install instructions on my LMDE6 install, Can I tweak it for my package base, please?
@Graham,
To fix the error, you need to create the missing directory.
After creating the directory, try running the installation steps again.
To fix “python: can’t open file” error, you need to check your Python version, if it is different than Python 3.8, you need to install or update your Python version.
After updating the Python version to 3.8, you need to update the path according to your actual directory structure.
Step 11 seems like a dead link
Please help…
@John,
I have added the working URL to install pgAdmin via pip.
Step 15 in Linux Mint 21 should be:
Can you provide the uninstall steps for the installation of PostgreSQL with pgAdmin4 you have provided?
@Frank,
Here are the instructions to uninstall PostgreSQL with pgAdmin4 on the Linux Mint system.
What is my postgresql password? I did the above but didn’t create a password.
@Yunus,
In step 14, you will be asked to set a master password, have you set it?
I have the “vera” mint 21.1 version, but following the procedure install version 14. I want postgreql version 15.
@Franco,
To install PostgreSQL 15 on Linux Mint, then follow these instructions:
Thank you very much brother, I was able to install it up to point 14, the rest was no longer necessary.
Remember to check the paths of the requests so that pgadmin4 runs.
Hey!
I’ve followed this guide, but step 13 does not work for some reason. I get this as an error message:
FileNotFoundError: [Errno 2] No such file or directory: ‘/home/*myname*/pgadmin/*~/.pgadmin’
What can I do?
@Anne,
Please create a config_local.py file as explained in step 12 to fix the error…
FTP server not functioning:
@Rick,
The complete URL for fetching and installing pgadmin4 is:
It does not work anymore, use 7.4 instead!
Hi,
I’ve performed as described in this article. Start PgAdmin in the terminal first, then in the browser. And in the browser, I see the empty tree of Servers in the left tab.
(Installed on Mint 21)
Hey, Guys!
I had this problem when running explain the analysis.
Do you have any suggestions?
Thanks!
:ERROR: unrecognized EXPLAIN option "summary"
SQL state: 42601
Hi, Thanks for the guide.
I am stuck on steps 12 and 13 of installing pgadmin. Do I open up a separate terminal tab to add the step 13 command?
@Steve,
Why are you stuck, I mean any errors you getting while running the command on step 12?
Hi Ravi,
Thanks for the reply. I am very new to linux. My confusion is after I copy and paste the code in Step 12 and hit enter, do I open up a new terminal tab to enter the Step 13 instructions? Because after entering the Step 12 instruction, I don’t get a prompt to enter a new instruction.
Thanks,
Steve
@Steve,
As explained in step #12, have you added the given code to the file config_local.py?
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:
I think that the suggested scripts for adding a repo to APT are for Mint 20. Is there an alteration needed for use with Mint 21?
Trying this in Mint 21. When I try
$ sudo /usr/pgadmin4/bin/setup-web.sh
I get
Setting up pgAdmin 4 in web mode on a Debian-based platform…
Creating configuration database…
/usr/pgadmin4/bin/setup-web.sh: line 75: /usr/pgadmin4/venv/bin/python3: No such file or directory
Error setting up server mode. Please examine the output above.
Looking in /usr/pgadmin4/venv/bin/ the symbolic links to python, python3 and python3.9 are showing as broken.
I have Python3.10 installed as default. Trying to install 3.9 as well (which I guess is probably a bad idea anyway?) results in
bio@bio-LIFEBOOK-S752:~$ sudo apt install python3.9
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
E: Unable to locate package python3.9
E: Couldn’t find any package by glob ‘python3.9’
Any suggestions are gratefully received.
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) root@usuario-Intel-powered-classmate-PC:~/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:
Hi 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 postgres
2) 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