PostgreSQL Service

PostgreSQL is a powerful, open source object-relational database system with over 35 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.

Zeabur provides a one-click deployment feature for PostgreSQL service, allowing you to deploy a PostgreSQL database on Zeabur in seconds.

ℹ️

At present, Zeabur's PostgreSQL service supports the latest version. More versions of the PostgreSQL service will be supported in the future, so stay tuned.

Deploy PostgreSQL Service

In your project page, click on Add service button and select Marketplace and then find PostgreSQL in the list.

Deploy PostgreSQL

After selecting PostgreSQL, Zeabur will automatically start deploying your PostgreSQL service.

Environment Variables

After you deploy the PostgreSQL service, Zeabur will automatically inject the relevant environment variables into other services.

  • POSTGRES_HOST
  • POSTGRES_PORT
  • POSTGRES_USERNAME
  • POSTGRES_PASSWORD

Sometimes, we can use the self-added DATABASE_URL to replace the above environment variables, for example:

postgres://<POSTGRES_USERNAME>:<POSTGRES_PASSWORD>@<POSTGRES_HOST>:<POSTGRES_PORT>/<DATABASE_NAME>

Here, <DATABASE_NAME> is the name of the database that you added yourself.

Adding a Database

By default, the username and database name in Zeabur's PostgreSQL are both root.

Sometimes you may need to add a databse to the PostgreSQL service, you can use the following methods to add a database.

PgAdmin

pgAdmin (opens in a new tab) is the most popular and feature-rich open-source management and development platform for PostgreSQL. You can use pgAdmin (opens in a new tab) to connect to the PostgreSQL database deployed on Zeabur.

Install PgAdmin

You need to install the pgAdmin client first. Go to pgAdmin's official website (opens in a new tab) to download and follow the instructions to install.

pgadmin

Add a Database

First, you need to click Add New Server and enter the relevant information:

connect-pgsql

Then, you can add a database in the Databases section.

create-db

PSQL (sql shell)

psql (opens in a new tab) is a terminal-based PostgreSQL tool. It allows you to enter queries interactively, send them to PostgreSQL, and view the query results. In addition, psql (opens in a new tab) provides many shell-like features to facilitate writing scripts and automating various tasks.

Install PSQL

To use PSQL, you need to install the PostgreSQL client first. Go to PostgreSQL's official website (opens in a new tab) to download and follow the instructions to install.

After the installation, you may need to restart your computer. You can check if the installation is successful by entering the following command:

psql --version

Add a Database

You can use psql (opens in a new tab) to connect to the PostgreSQL database deployed on Zeabur by simply entering the following command:

psql -h <POSTGRES_HOST> -p <POSTGRES_PORT> -U <POSTGRES_USERNAME> -W
CREATE DATABASE <DATABASE_NAME>;

Make sure to enter this command in the postgres=# state to execute it correctly.

psql-create-db