Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Using CLI to Connect to a FlexusRDS for PostgreSQL Instance

Updated on 2025-01-26 GMT+08:00

Scenarios

You can connect to your DB instance using the psql command-line interface (CLI) from a FlexusX instance with the PostgreSQL client installed.

Connecting to a FlexusRDS for PostgreSQL Instance Through a Client (PostgreSQL 15 and Earlier Versions)

  1. Log in to the FlexusX instance in the same region as your FlexusRDS DB instance.
  2. Install the PostgreSQL client.

    The PostgreSQL community provides client installation methods for different OSs. You can download and install the client using the installation tool of the OS. This installation method is simple but has requirements on the ECS OS. It is only available to the OSs supported by the PostgreSQL community.

    In this example, CentOS 7 is used. Use the default installation tool of the OS to install the client (PostgreSQL 15 or earlier).

    Figure 1 Obtaining the installation tool

    Run the following commands:

    sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    sudo yum install -y postgresql15-server

    Check whether the installation is successful.

    psql -V
    Figure 2 Successful installation
  3. Run the following command on the FlexusX instance to connect to the FlexusRDS for PostgreSQL DB instance:

    psql --no-readline -U<user>-h<host>-p<port>-d<datastore>-W

    Example:

    psql --no-readline -U root -h 192.168.0.44 -p 5432 -d postgres -W
    Table 1 Parameter description

    Parameter

    Description

    <host>

    NOTE:

    If the FlexusX instance and the FlexusRDS for PostgreSQL DB instance are in the same region and VPC, you are advised to connect to the DB instance through a private network for higher security.

    If a DB instance cannot be accessed through a private network, connect to it through a public network.

    <port>

    5432

    <user>

    root

    <datastore>

    postgres

  4. When the following information is displayed, enter the password of user root:
    Enter password:

Connecting to a FlexusRDS for PostgreSQL Instance Using Source Code (No Restrictions on the Version)

  1. Log in to the FlexusX instance in the same region as your FlexusRDS DB instance.
  2. Install the PostgreSQL client.

    Installation from source code: This installation method has no restrictions on the RDS PostgreSQL instance version and ECS OS.

    The following uses an ECS using the Huawei Cloud EulerOS 2.0 image as an example to describe how to install a PostgreSQL 16.4 client.

    Figure 3 Checking the ECS image
    1. To use SSL connection, download OpenSSL on the ECS in advance.
      sudo yum install -y openssl-devel
    2. Obtain the code download link, run wget to download the installation package to the ECS, or download the installation package to the local PC and upload it to the ECS.
      wget https://ftp.postgresql.org/pub/source/v16.4/postgresql-16.4.tar.gz
    3. Decompress the installation package.
      tar xf postgresql-16.4.tar.gz
    4. Compile and install the client.
      cd postgresql-16.4
      ./configure --without-icu --without-readline --without-zlib --with-openssl
      make -j 8 && make install
      NOTE:

      If --prefix is not specified, the default path is /usr/local/pgsql. The client can be installed in the simplest way.

      Figure 4 Compilation and installation
    5. Add the following code to the /etc/profile file to configure environment variables:
      export PATH=/usr/local/pgsql/bin:$PATH
      export LD_LIBRARY_PATH=/usr/local/pgsql/lib:$LD_LIBRARY_PATH
      source /etc/profile
    6. Test whether the psql is available.
      psql -V
      Figure 5 Testing psql
  3. Run the following command on the FlexusX instance to connect to the FlexusRDS for PostgreSQL DB instance:

    psql --no-readline -U<user>-h<host>-p<port>-d<datastore>-W

    Example:

    psql --no-readline -U root -h 192.168.0.44 -p 5432 -d postgres -W
    Table 2 Parameter description

    Parameter

    Description

    <host>

    NOTE:

    If the FlexusX instance and the FlexusRDS for PostgreSQL DB instance are in the same region and VPC, you are advised to connect to the DB instance through a private network for higher security.

    If a DB instance cannot be accessed through a private network, connect to it through a public network.

    <port>

    5432

    <user>

    root

    <datastore>

    postgres

  4. When the following information is displayed, enter the password of user root:
    Enter password:

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback