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.
Deploy PostgreSQL Service
To deploy this service, you will need to create a project first if you haven’t done so. You can follow this document to create your project.
In your project page, click on Add service button and select Marketplace and then find PostgreSQL in the list.
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 is the most popular and feature-rich open-source management and development platform for PostgreSQL. You can use pgAdmin 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 to download and follow the instructions to install.
Add a Database
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 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 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 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 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.