This topic describes general causes of the database connection error and solutions.
Error
ApsaraDB for OceanBase cannot be connected.
Causes
The database connection may fail due to one of the following causes:
Solutions
Check public and private IP addresses
Log on to the ApsaraDB for OceanBase console.
On the Clusters page, select the cluster to be checked. Click the name of the target cluster to go to the Cluster Workspace page.
In the left-side navigation pane, click Tenant Management to go to the Tenants page. Click the name of the target tenant to go to the Tenant Workspace page.
In the Deployment Diagram section, view your private and public IP addresses.
A private IP address is applied for a tenant during its creation by default. If a tenant needs to be connected over the public network, apply for a public IP address for it.
Check whitelist settings
Log on to the ApsaraDB for OceanBase console.
On the Clusters page, select the cluster to be checked. Click the name of the target cluster to go to the Cluster Workspace page.
In the left-side navigation pane, click Security Settings.
In the Whitelist Group section of the Security Settings page, check whether local IP addresses or CIDR blocks for the test connection have been added.
At present, the whitelist of ApsaraDB for OceanBase takes effect at the cluster level. Therefore, the whitelist cannot identify tenant types or distinguish private IP addresses from public ones.
When you specify public or private IP addresses in the whitelist for access to ApsaraDB for OceanBase, note the following rules:
Access from private IP addresses: The CIDR blocks specified in the whitelist must be the private IP addresses of ECS instances.
Access from public IP addresses: Make sure that the public IP addresses specified in the whitelist are those actually used for identifying the devices on the public network. For example, if the IP address is 127.0.0.1, no devices can access the tenant.
For more information about how to add a whitelist group, see Whitelist group.
Check the account password
Log on to the ApsaraDB for OceanBase console.
In the left-side navigation pane, click Clusters.
On the Clusters page, click the name of the target cluster to go to the Cluster Workspace page.
In the tenant list, click the name of the target tenant to go to the Tenant Details page.
In the left-side navigation pane, click Account Management.
On the Account Management page, find the target account in the list, and click Change Password in the Actions column to reset the account password and retry the connection.
When you connect to a database, avoid entering spaces at either end of the password string and make sure that no hidden characters are copied and pasted with the password.
Check the tenant mode of the connection
Log on to the ApsaraDB for OceanBase console.
In the left-side navigation pane, click Clusters.
On the Clusters page, click the target cluster to go to the Cluster Workspace page.
Click the target tenant in the Tenants list to go to the Tenant Workspace page of the Oracle or MySQL tenant.
On the Tenant Workspace page, click Log On to Database to log on to OceanBase Developer Center (ODC).
On the Private Connection tab of the ODC homepage, click Create Connection.
Specify the region of the tenant, which is Public Cloud. Specify the connection mode, which is MySQL or Oracle.
MySQL tenant: The format of OBClient connection string:obclient -h[tenant domain name] -u[tenant username] -P3306 -p[tenant password]
The format of OBClient connection string:obclient -h[tenant domain name] -u[tenant username] -P1521 -p[tenant password]
Check the network type of the ECS client
Make sure that the network type of the ECS client is VPC.
Check the regions of the ECS client and ApsaraDB for OceanBase instances
Make sure that the ECS client and the ApsaraDB for OceanBase instances are in the same region.
Check the VPCs of the ECS client and the tenant of ApsaraDB for OceanBase
To access a tenant in an ApsaraDB for OceanBase cluster from an ECS client over a private network, make sure that the client and the tenant use the same VPC.
This is required for standard cross-VPC connection where no special tools are used.
View the VPC of the tenant of ApsaraDB for OceanBase.
Log on to the ApsaraDB for OceanBase console.
In the left-side navigation pane, click Clusters.
On the Clusters page, click the name of the target cluster to go to the Cluster Workspace page.
Click the target tenant in the Tenants list to go to Tenant Workspace of the Oracle or MySQL tenant.
In the basic information section, view the value of User VPC.
View the VPC of the ECS client.
Log on to the ECS console.
In the left-side navigation pane, choose Instances and Images Instances.
In the Network Information section of the Instance Details tab, view the value of VPC.
Make sure that the value of User VPC of the ApsaraDB for OceanBase instance is the same as the value of VPC of the ECS client.