This topic describes how to use DMS or a client to connect to a PolarDB-O cluster.
- You have created a privileged account or standard account for a database cluster. For more information, see Create database accounts.
- You have added the IP address of the host that you want to connect to the Apsara PolarDB cluster to the whitelist. For more information, see Configure a whitelist for a cluster.
Use DMS to connect to a PolarDB-O cluster
Data Management (DMS) provides an integrated solution for data management. DMS supports data management, schema management, access control, BI charts, trend analysis, data tracing, performance optimization, and server management. DMS supports relational databases such as MySQL, SQL Server, and PostgreSQL, as well as NoSQL databases such as MongoDB and Redis. DMS also supports the management of Linux servers.
- Log on to the PolarDB console.
- On the top of the page, select the region where the target cluster is located.
- Find the target cluster and click the cluster ID to go to the Overview page.
- In the upper right corner of the Overview page, click Log On to Database to go to the RDS Database Logon page.
- On the RDS Database Logon page, enter the primary endpoint and the port number, and
separate them with a colon (:). Then, enter the username and password of the privileged
or standard account, and click Log On.When you connect to a cluster by using DMS, you can only use a primary endpoint. DMS does not support cluster endpoints.
Use a client to connect to a PolarDB-O cluster
You can also use the pgAdmin 4 client to connect to an Apsara PolarDB cluster.
- Launch the pgAdmin 4 client.
- Right-click Servers and choose , as shown in the following figure.
- On the General tab of the Create - Server dialog box that appears, enter the name of the server, as shown in the following
- Click the Connection tab and specify the information of the destination instance. These parameters are
listed in the following table.
Table 1. Parameters Parameter Description Host name/address
Enter the endpoint of the PolarDB-O cluster. To view the endpoint and port information of the PolarDB-O cluster, perform the following steps:
- Log on to the Apsara PolarDB console.
- In the upper-left corner of the console, select the region where the cluster is deployed.
- Find the target cluster and click the cluster ID.
- In the Endpoints section, view the endpoint and port information.
Port The port of the cluster. Default value: 1521. Maintenance database Enter the maintenance database. Default value: postgres. Username The username of the account of the PolarDB-O cluster. For more information, see Create database accounts. Password The password of the account for the PolarDB-O cluster.
- Click Save.
- If the connection information is valid, the following page appears after you click
the database name. This indicates that the connection is established.
- Right-click the target database and click Query Tool.... On the following page, you can add, delete, update, and query data in the database.
Use command lines to connect to a PolarDB-O cluster
In addition to the preceding methods, you can also download and install a client and use the CLI tool to connect to a PolarDB-O cluster.
- The IP address whitelist is invalid.
- The default whitelist contains only the IP address 127.0.0.1. 127.0.0.1 indicates that no IP address is allowed to access the cluster. Therefore, you must add IP addresses to the whitelist. For more information, see Configure a whitelist for a cluster.
- You have added 0.0.0.0 to the whitelist. The required format is 0.0.0.0/0.
Notice The CIDR block 0.0.0.0/0 indicates that all IP addresses are allowed to access the cluster. Use this CIDR block with caution.
- The public IP addresses you add to the whitelist are invalid. For example, the public IP address may be a dynamic IP address. The tools or websites used to query the public IP addresses provide invalid incorrect IP addresses.
- The internal or public endpoint is incorrectly used in the corresponding network.
The connection fails when you use an internal endpoint to connect over the Internet or use a public endpoint to connect over an internal network.
Use the required endpoint. If you want to connect to an Apsara PolarDB cluster over an internal network, you must use an internal endpoint. If you need to connect to the cluster over the Internet, you must use a public endpoint.