tencent cloud

TencentDB for PostgreSQL

ドキュメントTencentDB for PostgreSQLGetting StartedConnecting to TencentDB for PostgreSQL Instance

Connecting to TencentDB for PostgreSQL Instance

Download
フォーカスモード
フォントサイズ
最終更新日: 2026-05-15 14:51:36
You can connect to TencentDB for PostgreSQL using a standard SQL client via a private network address or a public network address.
Private Network Connection: Use a CVM to access the private network address automatically assigned to the cloud database. This connection method uses a high-speed private network, resulting in low latency. We recommend that the CVM and the database belong to the same account and reside within the same VPC (ensuring the same region) or both reside within the basic network.
Note:
For CVMs and databases under different VPCs (including same/different accounts, same/different regions), see Peering Connection for private network connection methods.
Public Network Connection: Connect to TencentDB for PostgreSQL via a public network address.
Note:
A public network connection requires enabling the public network address of the database instance. This operation will expose your database service to the public network, potentially leading to intrusion or attacks on the database. We recommend that you use private network access to log in to the database.
Public network connections for cloud databases are suitable for development or auxiliary database management tasks. They are not recommended for use by formal business access because uncontrollable factors, such as DDoS attacks or sudden high-traffic access, may cause public network access to become unavailable.
Public network access addresses can be enabled only for instances in Guangzhou, Shanghai, Beijing, Chengdu, Hong Kong (China), and Silicon Valley.
This section describes how to connect to TencentDB for PostgreSQL from a CVM running Windows or Linux, using either a private or public network connection.

Connecting from a Windows CVM Instance

1. Log in to a Windows CVM or work locally to download and install a standard SQL client.
Note:
This document uses pgAdmin as an example. You can download the installation program for a compatible version based on your system. For the download address, see pgAdmin.
2. Select Object > Create > Server from the top of pgAdmin.


3. In the Create - Server dialog box, enter the name, host IP address, port number, username, password, and other details, and then click Save.
Host IP address and port number: You can view them on the TencentDB for PostgreSQL console under the Private IPv4/IPv6 Address or Public IPv4/IPv6 Address on the instance details page. If the public network address is not enabled, see Enable Public Network Address to enable it.
Note:
The private network address here is a VIP. Access to the database instance is uniformly handled through the access gateway cluster, rather than by connecting directly to the physical server of the database instance. Therefore, the private IP address remains unchanged during host failures or primary-standby switches.
Username and password: Use the database administrator username and password set during instance initialization. If you forget the password, you can reset it on the console account management page.

4. After you log in to the database, choose Databases > postgres in the left sidebar to view the connected server (database instance).


Connecting from a Linux CVM Instance

1. Log in to a Linux CVM or work on a local Linux server to install a psql client via the yum repository.
2. To install the psql client, follow the instructions in Install PostgreSQL Database. The psql client will be installed automatically upon successful installation of PostgreSQL.
3. Run the following command to log in to the PostgreSQL database.
psql -U username -h access_address -p port -d postgres
Note:
If you are using a CVM within the same VPC as the database, you can directly use the database's private network address for access. If you are using a Linux server on the public internet, you must use the database's public network address for access.

Appendix: Enable Public Network Access Address

1. Log in to the TencentDB for PostgreSQL console. On the instance list page, click the instance ID or Manage in the Operation column to go to the instance details page.
2. On the instance details page, locate the Public IPv4 Address in the Basic Info section and click Enable.

3. After you click OK in the pop-up dialog box, the public network activation enters the processing state.
4. After the public network is successfully enabled, you can view the public network address in the Basic Info section.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック