PostgreSQL Server¶
Operating System:
Terminal:
Shell:
Editor:
Package Manager:
Programming Language:
Database:
Extension:
Operating System:
Terminal:
Shell:
Editor:
Package Manager:
Programming Language:
Database:
Extension:
Operating System:
Terminal:
Shell:
Editor:
Package Manager:
Programming Language:
Database:
Extension:
Operating System:
Terminal:
Shell:
Editor:
Package Manager:
Programming Language:
Database:
Extension:
PostgreSQL is an object-relational database management system based on POSTGRES 4.2.
For more information, check the official documentation here.
Initialization¶
For information on how to use the Initialization parameter, please refer to the Use Cases section of the documentation.
Create a New Server¶
The app requires to set the parameter PGDATA, which is used to import the PostgreSQL database folder from a UCloud workspace.
If the folder is empty, a new database will be initialized. In this case, after the initialization procedure is completed, the following lines will be displayed in the output logs:
Tip
PostgreSQL init process complete; ready for start up.
2025-08-22 13:24:04.753 CEST [317] LOG: starting PostgreSQL 17.6 (Debian 17.6-1.pgdg13+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 14.2.0-19) 14.2.0, 64-bit
2025-08-22 13:24:04.843 CEST [317] LOG: listening on IPv4 address "0.0.0.0", port 5432
2025-08-22 13:24:04.864 CEST [317] LOG: listening on IPv6 address "::", port 5432
2025-08-22 13:24:04.912 CEST [317] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2025-08-22 13:24:05.461 CEST [517] LOG: database system was shut down at 2025-08-22 13:24:03 CEST
2025-08-22 13:24:05.495 CEST [317] LOG: database system is ready to accept connections
The name of the PostgreSQL superuser is ucloud. A new superuser can be defined via the POSTGRES_USER optional parameter.
By default, the database name and the superuser password are both equal superuser name. These can be changed using the parameters POSTGRES_PASSWORD (or POSTGRES_PASSWORD_FILE) and POSTGRES_DB, respectively.
Note
Additional arguments for the database initialization can be passed as a string using the POSTGRES_INITDB_ARGS option.
To access and modify the PostgreSQL server, the user should open the app terminal interface and access the database with the command:
$ psql <db>
where <db>
must be replaced with the name of the database. There is no need to add the admin password to login from the app terminal.
Connect to the Server¶
As previously discussed, users can access the PostgreSQL console directly through the app’s terminal interface. Alternatively, it is also possible to connect to the server using an external client application.
If the client application runs within another interactive app available on UCloud, one can connect directly to the PostgreSQL server as described here. In this case the server hostname is configured as an external parameter via the Connect to other jobs optional parameter.
If, however, the PosgreSQL client is a third-party application not running on UCloud, it is necessary to assign a static IP address to the server, using the Add public IP option. In addition, it is necessary to edit the client configuration file pg_hba.conf
and change the lines referring to the host as reported below:
# IPv4 local connections:
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::0/0 md5
Notice that, by default, the main configuration file postgresql.conf
, located in the database folder, is created with the line: listen_address = '*'
. This setting allows connections from all available IP interfaces.
Note
By default remote access to the PostgreSQL server is established via a TCP/IP connection over port 5432
. The static IP address must listen to the same port to establish connection.
Start pgAdmin¶
To launch the pgAdmin 4 web interface, set the optional Enable pgAdmin Web UI flag to true when starting the job. fter the interface starts, it can be accessed through a browser to manage PostgreSQL databases. The automatically generated login credentials are provided in the job output logs.
Contents