This topic describes how to connect to an ApsaraDB RDS for PostgreSQL instance. After you complete the initial configurations, you can connect to your RDS instance from an Elastic Compute Service (ECS) instance or your computer.
You can connect to an RDS instance by using Data Management (DMS) or a client such as pgAdmin 4.
You can log on to DMS from the ApsaraDB for RDS console and then connect to an RDS instance.
DMS is an all-in-one data management service that supports data and schema management, access security, BI charts, data trends, data tracking, performance trends and optimization, and server management. DMS can be used to manage NoSQL databases and relational databases, such as MySQL, SQL Server, PostgreSQL, MongoDB, and Redis. It can also be used to manage Linux servers.
You can also use a client to connect to an RDS instance. ApsaraDB RDS for PostgreSQL is fully compatible with PostgreSQL. You can connect to an RDS for PostgreSQL instance in the similar way that you connect to an on-premises PostgreSQL instance. This topic takes the pgAdmin 4 client as an example to introduce how to connect to an RDS instance. You can also adopt this method when you use other clients. When you connect to an RDS instance by using a client, you must select its internal or public endpoint based on your network environment:
- If the client is deployed on an ECS instance that resides in the same region and has the same network type as the RDS instance, you can use the internal endpoint. For example, if the ECS and RDS instances both reside in VPCs in the China (Hangzhou) region, use the internal endpoint to establish a secure connection.
- In the other situations, use the public endpoint.
Use DMS to connect to an RDS instance
For more information, see Use DMS to log on to an RDS instance.
Use a client to connect to an RDS instance
- Add the IP address that requires access to the RDS instance to a whitelist of the RDS instance. For more information, see Configure a whitelist for an RDS PostgreSQL instance.
- Start the pgAdmin 4 client.
Note In some versions of pgAdmin, if it is the first time that you log on to the pgAdmin client, you must specify a master password that is used to protect the saved passwords and other credentials.
- Right-click Servers and choose .
- On the General tab of the Create - Server dialog box, enter the server name.
- Click the Connection tab and enter the information of the RDS instance.
Parameter Description Hostname/address Enter the endpoint of the RDS instance. If you want to connect to the RDS instance over an internal network, enter its internal endpoint. If you want to connect to the RDS instance over the Internet, enter its public endpoint. For more information, see View and change the internal and public endpoints and ports. Port Enter the port number that is associated with the endpoint. Username Enter the username of the account that is used to log on to the RDS instance. Password Enter the password of the account that is used to log on to the RDS instance.
- Click Save.
- If the information of the RDS instance is correct, the following page is displayed,
which indicates that the connection to RDS instance is successful.
Note postgres is the default system database of the RDS instance. Do not perform any operation in this database.
How do I enable Function Compute to obtain data from an RDS instance?
You can install third-party dependencies for your functions in Function Compute and use built-in modules to obtain the data of an RDS instance. For more information, see Install third-party dependencies.