PostgreSQL Service
Zeabur provides a one-click deployment feature for PostgreSQL service, allowing you to quickly deploy a PostgreSQL database on Zeabur.
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.
Deploying PostgreSQL Service
In your project, click on Deploy new service and select Deploy PostgreSQL from the Deploy Other Services options.
After clicking Deploy, Zeabur will automatically deploy the PostgreSQL service for you.
Environment Variables
After you deploy the PostgreSQL service, Zeabur will automatically inject the relevant environment variables into other services.
POSTGRESQL_HOST
POSTGRESQL_PORT
POSTGRESQL_USERNAME
POSTGRESQL_PASSWORD
Sometimes, we can use the self-added DATABASE_URL
to replace the above environment variables, for example:
postgres://<POSTGRESQL_USERNAME>:<POSTGRESQL_PASSWORD>@<POSTGRESQL_HOST>:<POSTGRESQL_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
. Here, we need to add the first database ourselves, which can be done in the following ways.
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.
First, you need to click Add New Server and enter the relevant information:
Then, you can add a database in the Databases section.
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.
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 <POSTGRESQL_HOST> -p <POSTGRESQL_PORT> -U <POSTGRESQL_USERNAME> -W
CREATE DATABASE <DATABASE_NAME>;
Make sure to enter this command in the postgres=#
state to execute it correctly.