PostgreSQL: Using the PostgreSQL psql CLI

This documentation is part of the Getting Started guide. You can view the complete guide here: How to Get Started with PostgreSQL.

👋 Welcome to the Stackhero documentation!

Stackhero offers a fully managed PostgreSQL cloud solution, designed for reliability and performance:

  • Unlimited connections and data transfers for effortless scalability.
  • PgAdmin web interface included for easy database management.
  • Popular extensions included, such as PostGIS, TimescaleDB, and PgVector.
  • Simple, one-click updates to keep your database secure and up to date.
  • High performance and enhanced security on private, dedicated infrastructure.

Save time and make your life easier: it only takes 5 minutes to try Stackhero's PostgreSQL cloud hosting solution!

You can manage PostgreSQL with its official psql CLI. It is available for installation on your computer, allowing you to manage your PostgreSQL service remotely. Alternatively, you can run it via Docker. This method is often preferred because it avoids installing psql directly on your computer and makes it easier to switch between versions.

To access psql using Docker, run the following command (make sure to replace 18 with the major version number of your PostgreSQL service):

docker run -v $(pwd):/mnt -it postgres:18-alpine /bin/bash

Then connect to your PostgreSQL service using:

cd /mnt
psql \
  --host=<XXXXXX>.stackhero-network.com \
  --username=admin \
  --port=<PORT> \
  --dbname=admin