Quick Start
Install pgcli and create your first PostgreSQL instance.
Get pgcli up and running in minutes.
Installation
Install pgcli with a single command:
This script will:
- Download the latest pgcli binary for your platform
- Install it to
/usr/local/bin(or~/.local/binif no sudo) - Add pgcli to your PATH
Initialize Configuration
This creates ~/.pgcli/pg.yaml with sensible defaults including:
- A default instance named
default - Data directory at
/data/pg/default - Auto-assigned ports starting from 35432
Start Instance
The output shows the connection URL, admin password, and backup status.
Connect to Your Database
Basic Operations
Multi-Instance
Multiple Config Files (Isolation)
For isolated testing environments or one config per project on the same host,
generate a separate config file per environment with a distinct --namespace
and disjoint port ranges.
| Parameter | Default | Meaning |
|---|---|---|
--namespace |
default |
Container name prefix: pgcli-pg-<namespace>-<instance> |
--pg-start-port |
35432 |
First PG host port; instances get sequential ports |
--pg-ssh-port |
42201 |
First SSH host port; sequential from here |
Planning tips:
- Always pass an explicit
--namespaceto avoid container name clashes. - Port ranges must not overlap between configs on one host.
- The namespace is baked into container names at creation time. Changing it later requires
pg destroyand re-init.
Interactive psql Session
Inside the interactive psql shell you get:
- SQL queries with history and tab completion
- psql meta-commands (
\dt,\du,\l, etc.) \qto quit
Container Shell
The shell runs as root inside the container, giving full access to:
- PostgreSQL data directory (
/var/lib/postgresql/data) - Configuration files
- Log files (
/var/log/postgresql/) - All system tools and utilities
Next Steps
- Learn about backup and restore
- Set up replication for high availability
- Explore extensions management
- Understand administration