Now that pgAdmin 4 is out you may want to install it on your linux machine.
As for debian/ubuntu at least there aren't any packages build yet here's a way to do it.
Create a Python 3 virtual environment
You can do without a virtual environment but that's how I like to do things.
Install the needed packages (you can also build Python from source if you fancy another Python version that what you already have in your OS) with sudo apt-get install python3-dev python3-venv wget
Create a virtual environment and activate it with:
python3 -m venv pgadmin4 && source pgadmin4/bin/activate
Download, configure and run
wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v6.11/pip/pgadmin4-6.11-py3-none-any.whl
pip install wheel
pip install pgadmin4-6.11-py3-none-any.whl
As I want to use the Desktop
mode I created the pgadmin4/lib/python3.9/site-packages/pgadmin4/config_local.py
file and I added according to my usual login user, qgis
:
SERVER_MODE = False
LOG_FILE = '/home/qgis/.pgadmin/pgadmin4.log'
SQLITE_PATH = '/home/qgis/.pgadmin/pgadmin4.db'
SESSION_DB_PATH = '/home/qgis/.pgadmin/sessions'
STORAGE_DIR = '/home/qgis/.pgadmin/storage'
Run python pgadmin4/lib/python3.9/site-packages/pgadmin4/setup.py
and the setup should be completed.
Depending on your setup, if you encounter permissions errors you should re-run the above command after you fix them.
You can test that everything works as it should by doing python pgadmin4/lib/python3.9/site-packages/pgadmin4/pgAdmin4.py
and by opening your web browser to http://localhost:5050
Create a service
Create a /etc/systemd/system/pgadmin4.service
service file containing:
[Unit]
Description=Pgadmin4 Service
After=network.target
[Service]
User=qgis
Group=qgis
WorkingDirectory=/home/qgis/Downloads/pgadmin4/
Environment="PATH=/home/qgis/Downloads/pgadmin4/bin"
ExecStart=/home/qgis/Downloads/pgadmin4/bin/python /home/web/Downloads/pgadmin4/lib/python3.9/site-packages/pgadmin4/pgAdmin4.py
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Run the service with sudo systemctl start pgadmin4
.
Test if everything is fine by doing sudo systemctl status pgadmin4
.
Set it up to autostart when linux boots by doing a sudo systemctl enable pgadmin4
.
That's it!