tencent cloud

Feedback

Connecting to TencentDB for PostgreSQL Instance

Last updated: 2024-01-24 11:08:34
    You can use a standard SQL client to access it over the private network or public network.
    Private network access: a CVM instance can be used to access the private network address automatically assigned to the TencentDB instance. This access method relies on the high-speed private network of Tencent Cloud and features low delay. The two instances must be under the same account and in the same VPC in the same region or both must be in the classic network.
    Note:
    CVM and TencentDB instances in different VPCs (under the same or different accounts in the same or different regions) can be interconnected over private network through Peering Connection.
    Public network access: TencentDB for PostgreSQL can be accessed by using a public network address.
    Note:
    For public network access, the database instance's public IP needs to be enabled, which may expose your database service to attacks or intrusions on the public network. Therefore, it is recommended to log in to the database over the private network.
    Public network access to TencentDB is suitable for development or auxiliary management of databases but not for business access in the production environment, as potentially uncontrollable factors may lead to unavailability of the public network access, such as DDoS attacks and bursts of high-traffic access.
    Instances that currently support public network access are available only in Guangzhou, Shanghai, Beijing, Chengdu, Hong Kong (China), and Silicon Valley.
    The following describes how to connect to a TencentDB for PostgreSQL instance from Windows and Linux CVM instances over the private and public networks.

    Connecting from a Windows CVM Instance

    1. Download and install a standard SQL client in a Windows CVM instance or locally. For more information about how to log in to a CVM instance, please see Customizing Windows CVM Configurations.
    Note:
    Take pgAdmin for example. You can download an installer here based on your operating system version.
    2. In pgAdmin, select Object > Create > Server.
    
    
    3. In the Create - Server dialog box, enter the information such as host name/address, port number, username, and password and then click Save.
    Host name/address and port number: you can go to the TencentDB for PostgreSQL console and view them in Private IPv4/IPv6 Address or Public IPv4/IPv6 Address in the Basic Info section on the instance details page. If the public IP is not enabled, please see Enabling Public Network Access.
    Note:
    Here, the private IP is VIP; database instances are accessed by connecting to the gateway cluster rather than the physical servers of database instances directly. Therefore, the private IP will remain unchanged in the event of server failures or primary/standby switchover.
    Username and password: use the database admin username and password set when the instance is initialized. If you forget the password, you can go to the account management page in the console to reset it.
    
    
    4. Then, select Databases > postgres on the left sidebar to view the connected server (database instance).
    
    

    Connecting from a Linux CVM Instance

    1. Install a psql client via yum in a Linux CVM instance or locally. For more information about how to log in to a CVM instance, please see Customizing Linux CVM Configurations.
    2. To install a psql client, please follow the instructions in Restoring PostgreSQL Data on CVMs > Install PostgreSQL to install PostgreSQL, as the psql client will be installed along with PostgreSQL.
    3. Run the following command to log in to the PostgreSQL database:
    psql -U username -h access address -p port -d postgres
    Note:
    To access from a CVM instance in the same VPC of the database instance, use the private IP of the database instance as the access address. To access from a Linux server on the internet, use the public IP of the database instance as the access address.

    [Appendix. Enabling Public Network Access]

    1. Log in to the TencentDB for PostgreSQL console. In the instance list, click the instance ID/name or Manage in the Operation column to access the instance details page.
    2. Click Enable next to Public IPv4/IPv6 Address in the Basic Info section on the instance details page.
    
    3. Click OK in the pop-up window and the request to enable public IP will be processed.
    4. Once enabled successfully, the public IP can be found in the Basic Info section.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support