pgAdmin is the leading Open Source feature-rich PostgreSQL administration and development platform that runs on Linux, Unix, Mac OS X, and Windows. It provides a powerful GUI which ease your Database management and operations.

pgAdmin allows you to manage PostgreSQL 9.2 and above. As of this writing, the latest release of pgAdmin is v4 which had migration from Bootstrap 3 to Bootstrap 4.

Setup Pre-requisites

As a pre-requisite, you need to have:

  • FreeBSD server
  • PostgreSQL server installed
  • User account with sudo privileges

Step 1: Install PostgreSQL database server

For the installation of PostgreSQL database server, refer to our previous guide:

How to Install PostgreSQL 11 on FreeBSD 12

Step 2: Update FreeBSD system

In my setup, I’m installing pgAdmin on the same server running PostgreSQL. But you have an option of setting it up on a different server.

First update the FreeBSD Repository Database.

freebsd-update fetch
freebsd-update install

Step 3: Install Python pip & Virtualenv

pip is required for installing Python packages. Install it on your FreeBSD server by following below guide.

How to Install pip Python package manager on FreeBSD 12

Once pip is installed, install virtualenv package.

sudo pkg install py36-virtualenv

if you’re using Python 2.7, then run:

sudo pkg install py27-virtualenv

Step 4: Install pgAdmin packages

Create a virtual environment for pgAdmin4 by running:

$ virtualenv-3.6 pgadmin4
Using base prefix '/usr/local'
New python executable in /home/vagrant/pgadmin4/bin/python3.6
Also creating executable in /home/vagrant/pgadmin4/bin/python
Installing setuptools, pip, wheel…done.

For Python 2.7, this should be

virtualenv pgadmin4

Activate the Virtual environment created:

source pgadmin4/bin/activate

If it fails, use:

source pgadmin4/bin/activate.csh

Install Python dependencies for pgAdmin:

pip install pyopenssl cryptography pyasn1  ndg-httpsclient 

Then install the standard Python binding to the SQLite3 library. For python 3.6, run:

sudo pkg install py36-sqlite3

For Python 2.7, use:

sudo pkg install py27-sqlite3

Check for the latest release of pgAdmin4 before downloading. Once you get the path to latest release, install it with the pip command.

pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.1/pip/pgadmin4-4.1-py2.py3-none-any.whl

This installation may take some time as a number of dependencies are installed, so be patient.

Step 5: Configure and run pgAdmin 4

After the installation, configuration file should be created for pgAdmin 4.

cp ./pgadmin4/lib/python3.6/site-packages/pgadmin4/config.py ./pgadmin4/lib/python3.6/site-packages/pgadmin4/config_local.py

For Python 2.7, replace python3.6 with python2.7

Change the default server Listen address on to 0.0.0.0

vim ./pgadmin4/lib/python3.6/site-packages/pgadmin4/config_local.py

This is around line 138

DEFAULT_SERVER = '0.0.0.0'

The default listen port is 5050 but you can change it to your desired port.

The default port on which the app server will listen if not set in the environment by the runtime
DEFAULT_SERVER_PORT = 5050

Use following command to run pgAdmin.

$ sudo python ./pgadmin4/lib/python3.6/site-packages/pgadmin4/pgAdmin4.py
NOTE: Configuring authentication for SERVER mode.
Enter the email address and password to use for the initial pgAdmin user account:
Email address: [email protected]
Password: <Enter Password>
Retype password: <Confirm Password>
pgAdmin 4 - Application Initialisation
Starting pgAdmin 4. Please navigate to http://0.0.0.0:5050 in your browser.

The first run will ask you to Enter the email address and the password to use for the pgAdmin user account.

Step 6: Access pgAdmin Web Interface

Now that we have pgAdmin4 installed and running, you can access its web dashboard by visiting the URL “http://your_server_ip:5050“.

Login with created user email address and password. After login, you’ll need to connect to your PostgreSQL server.

Enter server connection name and group.

Under “Connection” tab, provide access details – DB host, DB user and Password.

Save the settings to activate your connection.

You can now enjoy using pgAdmin for your PostgreSQL database management tasks.

If you’re a MariaDB user, check: How to Install MariaDB 10.3 on FreeBSD 12

How to Install PHP 7.3 on FreeBSD 12