All Products
Search
Document Center

AnalyticDB:psql

Last Updated:Mar 28, 2026

psql is a command-line interface (CLI) tool for connecting to and querying an AnalyticDB for PostgreSQL instance.

Prerequisites

Before you begin, ensure that you have:

  • The internal or public endpoint of the AnalyticDB for PostgreSQL instance

    • Internal endpoint: Use when your client runs on an Elastic Compute Service (ECS) instance in the same region and the same network type as the AnalyticDB for PostgreSQL instance. To find the internal endpoint, go to the AnalyticDB for PostgreSQL console, open the instance, and check internal endpoint in the Database Connection Information section of the Basic Information page.

    • Public endpoint: Use when your client runs on an ECS instance in a different region or network type, or on a system outside Alibaba Cloud. Apply for a public endpoint first. For details, see Manage public endpoints.

  • The IP address of your client added to an IP address whitelist of the instance. For details, see Configure an IP address whitelist

Download and install psql

The installation packages support Red Hat Enterprise Linux (RHEL) 6 or 7 and CentOS 6 or 7.
  1. Download the installation package for your engine version and operating system:

    Engine versionOperating systemDownload link
    AnalyticDB for PostgreSQL V7.0RHEL 7 or CentOS 7adbpg7_client_package.el7.x86_64.tar.gz
    AnalyticDB for PostgreSQL V6.0RHEL 7 or CentOS 7ADBPG_client_package_el7
    AnalyticDB for PostgreSQL V6.0RHEL 6 or CentOS 6ADBPG_client_package_el6
  2. Decompress the package:

    tar -xzvf <installation-package-name>

    Example:

    tar -xzvf adbpg_client_package.el7.x86_64.tar.gz
  3. Switch to the bin directory:

    cd adbpg_client_package/bin

    The bin directory contains psql and pg_dump. pg_dump is a logical backup tool for PostgreSQL. For usage details, see pg_dump.

Connect to an instance

Before running the connection command, collect the following values from the Database Connection Information section of the Basic Information page in the AnalyticDB for PostgreSQL console:

  • Endpoint (internal or public)

  • Port

  • Database name (default: postgres)

  • Database account and password

Connect using either of the following methods:

Connection string:

psql "host=yourgpdbaddress.gpdb.rds.aliyuncs.com port=5432 dbname=postgres user=gpdbaccount password=gpdbpassword"

Separate parameters:

psql -h yourgpdbaddress.gpdb.rds.aliyuncs.com -p 5432 -d postgres -U gpdbaccount
ParameterDescription
-hEndpoint of the instance
-pPort number
-dDatabase name. Default: postgres
-UDatabase account

Enter the password when prompted to go to the psql CLI.

Run psql --help to view all available options. Inside the psql session, run \? to view all supported psql commands.

Connect using Docker (V6.0 only)

As an alternative for AnalyticDB for PostgreSQL V6.0, use the Docker toolbox. Install Docker first. For instructions, see the Docker official website.

Run the following commands:

docker run -idt --name=adbpgcli aliadbpg/adbpgcli:v6.3.0
docker exec -it adbpgcli /bin/bash -l

References