For the complete documentation index, see llms.txt. This page is also available as Markdown.

35.3 pgAdmin4

Warning

Please note the following upstream known issues: pgAdmin4 running on FreeBSD may be affected by Bug 7836 and Bug 8869.

This section is based on the FreeBSD 14.3-RELEASE operating system environment.

pgAdmin4 is an open-source software for managing PostgreSQL database servers, and is also the officially recommended graphical management tool for PostgreSQL. pgAdmin4 is written in Python (Flask framework) and React, supports multiple operating system environments (such as Windows, UNIX, Linux, etc.), and can run in both desktop mode and server mode.

Note

pgAdmin4 is installed via pip and uses SQLite to store its own configuration data; it can run without a locally installed PostgreSQL database. However, it needs to connect to a PostgreSQL database server to fully utilize its management capabilities.

pgAdmin4 requires a Python environment to run, and installation requires the Python pip package management tool, so Python must be installed first. This section uses the system's default Python version as an example. Note that FreeBSD systems may not have Python installed by default; you can verify this by launching the Python interpreter:

# python
python: Command not found   # Indicates that the Python environment is not currently installed

Tip

You can use the following command to check the installed Python 3 version:

$ python3 -V
Python 3.11.12

Installing Python and pip

Install using pkg:

# pkg install python3 py311-pip

Or using Ports:

Note: pip is the Python package manager, used to install and manage Python packages and their dependencies.

Installing and Configuring virtualenv

virtualenv is used to create independent Python virtual environments.

This section uses virtualenv to create an independent Python environment for installing pgAdmin4.

The following command is used to install virtualenv:

Install using pkg:

Install using Ports:

Create a Python virtual environment named pgadmin4 (virtual environment) by running the following command:

After creation is complete, the following information will be displayed:

A virtual environment named pgadmin4 has been generated in the root user's home directory (/root) (other file outputs omitted):

File Structure

The file structure of pgAdmin4 is as follows.

Installing sqlite3

Install using pkg:

Tip

Note that the version must match Port lang/python.

Or install using Ports:

Activate the pgAdmin4 virtual environment (you need to add . (dot) and a space before the command):

You can see that the shell prompt has changed to (pgadmin4) (all subsequent operations are performed in this shell):

Installing pgAdmin4

The current pip source requires HTTPS; if the system lacks SSL certificates, you need to install the certificate package first.

If you encounter network issues, you can switch to a pip mirror source. Set it to the Tsinghua University mirror source:

Install dependencies, including the OpenJPEG library and the Rust programming language environment:

Install the specified version of pgAdmin4 (version 9.4):

Note

If memory is insufficient (less than 4 GB) and there is no swap, it will show killed; if this problem occurs, please add swap space first.

Troubleshooting

If the following error occurs:

The above error is caused by inaccurate system time; use ntpd -q -g pool.ntp.org to synchronize the system time to resolve it. For detailed instructions, refer to other relevant chapters in this book.

Configuring and Running pgAdmin4

After installation is complete, pgAdmin4 needs to be configured before it can run properly.

After installation, create the pgAdmin4 local configuration file (note the Python version):

Warning

Do not directly copy ./pgadmin4/lib/python3.11/site-packages/pgadmin4/config.py to ./pgadmin4/lib/python3.11/site-packages/pgadmin4/config_local.py, otherwise no configuration changes will take effect; please create an empty file directly.

Edit the configuration ./pgadmin4/lib/python3.11/site-packages/pgadmin4/config_local.py. Example:

  • DEFAULT_SERVER changes the default server listening address to 0.0.0.0.

  • DEFAULT_SERVER_PORT can modify the port that the application listens on.

Manually create the pgAdmin4 data and log directories:

After editing the configuration file, execute the following command to initialize the login account and password.

Start the pgAdmin4 application:

Example output:

At this point, pgAdmin4 has been installed and is running; you can access the web control panel via http://ip:5050:

Log in to pgAdmin4

The area indicated by the arrow allows you to switch languages.

pgAdmin4 switch language
pgAdmin4 Chinese interface

Keeping pgAdmin4 Running in the Background

After the service is stopped, if you need to run it again, use the pgadmin4 installation user (in this case root) to enter their home directory and execute the following commands to activate the pgadmin4 virtual environment and start the service (& indicates running in the background):

Upgrading pgAdmin4

If you need to upgrade pgAdmin4, follow the steps below.

In this test, directly using pip to upgrade pgAdmin4 may still display old version information.

pgAdmin4 is updated frequently; if you need to upgrade, you must first delete the original pgadmin4 directory created with virtualenv, then use the installation user to execute the following command again to create the Python virtual environment pgadmin4:

After the virtual directory is created, activate the pgadmin4 virtual environment:

After activation, do not start the service; directly upgrade pgAdmin4 to the latest version:

After the upgrade is complete, start the pgAdmin4 application:

The login account and password remain unchanged (after logging in, there will be no update prompt; the version is already the latest).

References

  • FreeBSD Project. PostgreSQL/Setup - FreeBSD Wiki[EB/OL]. (2024-06-09)[2026-03-25]. https://wiki.freebsd.org/PostgreSQL/Setup. Systematically introduces the installation and configuration methods for PostgreSQL on FreeBSD, providing official guidance reference for this section.

  • pgAdmin Development Team. pgAdmin 4 GitHub Repository[EB/OL]. [2026-04-17]. https://github.com/pgadmin-org/pgadmin4. The official pgAdmin 4 repository, documenting its technology stack as a Python (Flask) backend with a React frontend.

Last updated