Background information
OceanBase Developer Center (ODC) allows you to connect to OceanBase Database to edit and manage data sources, including database objects and resources. ODC can connect to OceanBase Database in MySQL and Oracle modes on Apsara Stack and Alibaba Cloud.
This topic describes how to create a data source in ODC.
Prerequisites
You have deployed Web ODC.
You have deployed and logged on to Web ODC.
You have obtained the connection information or connection string of the data source instance. A connection string is in the format of
mysql -h host name -P port number -u database username@tenant name#cluster name-D default database -p 'database password'. Here is an example of a connection string:-hxxx.x.x.x -P8080 -uodc@mysql_tenant#odc_cluster -Dodc -p'******'
Procedure
Create a single data source
Example: Create an OceanBase data source in MySQL mode in ODC.
| Parameter | Example value |
|---|---|
| Data source name | mysql4.2.0 |
| Host IP address | xxx.x.x.x |
| Port | 8080 |
| Cluster name | odc_cluster |
| Tenant name | mysql_tenant |
| Database username | odc |
| Database password | ****** |
| sys tenant account | test |
| sys tenant password | ****** |
Log on to Web ODC. In the left-side navigation pane, choose Data Source > Create Data Source.

In the Create Data Source panel, specify the following information.
Note
If you have obtained the connection string of OceanBase Database, you can obtain the following information from the connection string or use the Intelligent Parsing tool provided on the tab to fill in the information.

Parameter Description Data Source Type OceanBase is selected by default. Intelligent Parsing You can paste a connection string to the field. ODC automatically identifies the string and fills in the corresponding values. Connection Type The type of the target database. ODC supports the following database types: - OceanBase MySQL or OceanBase Oracle: a database instance that you build in your own environment.
- OB Cloud MySQL or OB Cloud Oracle: a database instance on Alibaba Cloud.
- OB Sharding MySQL: a logical database, which supports only the MySQL mode.
Endpoint - Host IP: the IP address of the server where the target database is located.
- Port: the port number of the server where the target database is located.
- Cluster: the name of the cluster where the target database is located. This parameter is not required for logical databases.
- Tenant: the name of the tenant in which the target database is located. This parameter is not required for logical databases.
Note
- You can obtain the host name and port number from the details page of the tenant in which the target database is located, such as a tenant created on Alibaba Cloud or in OceanBase Cloud Platform (OCP).
- The cluster name is required only when you connect to OceanBase Database by using an OBProxy.
Database Account - Account: the username of an account created in the tenant. In MySQL mode, this account must have the privilege to access the default database.
- Password: the password of the account created in the tenant. You can click Test Connection next to the password field to test whether you can connect to the target database.
Note
- An error will be returned if the configurations such as the username, password, or network settings are invalid.
- You can connect only to a database in the current tenant. Otherwise, a test failure error will be returned.
- Before you save the configurations, you can click Test Connection to test the database connection. If the database username and password are correct, the system returns a message indicating that the connection succeeded. If you use ODC V4.0.0 and later, you can save the connection without setting the database account and password.
Environment You can select the environment type based on your needs. Valid values: dev, sit, and prod. sys Tenant Account Settings Choose whether to select Query Tenant Views with sys Tenant Account. If you select this option, specify Account and Password.
When the database is a physical database, you can specify an account that has the privilege to query the sys tenant views and the password. This field is automatically filled in when sys is specified as the tenant in Endpoint.- Account: an account that has the privilege to query the views in the sys tenant.
- Password: the password of the account.
Note
- In ODC V2.3.0 and later versions, to use the import and export features, you must configure the root@sys account in the Advanced Configuration section when you create a connection.
- In ODC V2.4.1 and later versions, the dependency of the import and export features on the root@sys user is removed when you query views. If the root@sys account is not configured, some ODC objects such as stored procedures and functions do not support the export feature. If the root@sys account is configured, you can access the views under the sys tenant to obtain the optimal data routing strategy, which can increase the export speed.
- The account and password of the sys tenant are the account and password of a user in a cluster tenant. Do not enter "@sys#cluster" in the Account field. For example, the
rootaccount can be used.
Enable SSL Specifies whether to enable SSL link encryption to ensure secure data transmission between clients and servers. Note
- By default, the
REQUIRE NONEoption is specified when you create a user. TheREQUIRE NONEoption specifies that no encryption method is used. In this case, if you select Enable SSL, an SSL connection is created. Otherwise, a regular connection is created. - If the
REQUIRE SSLoption is specified when you create the user, you must select Enable SSL to create an SSL connection. Otherwise, the connection fails.
If the user is created by specifying theREQUIRE SSLoption, you do not need to upload the certificates, but you must select Enable SSL. Otherwise, the connection fails. We recommend that you upload the following certificates for identity verification:- CA certificate: The client will verify the identity of the server.
- Client key and client certificate: The server will verify the identity of the client.
- If the user is created by specifying the
REQUIRE X509option, you must select Enable SSL and upload the CA certificate, client key, and client certificate. The client and server will verify the identity of each other. If you do not select Enable SSL or do not upload the certificate, you cannot create a connection.
After you specify the preceding information, click Save in the lower-right corner of the panel.
In the dialog box that appears, specify the data source name and click OK.
The data source is then saved to the ODC data source list.
Note
- You can click Copy Connection String in the lower-right corner of the Create Data Source panel to copy the connection information being edited on the current panel as a connection string. This allows you to obtain the connection information with ease.
- If you do not want to save the current connection configuration, click Cancel. In the dialog box that appears, confirm whether to exit the data source creation page.
After the data source is created, you can view the data source in the data source list.
Import multiple private connections at a time
ODC V4.2.0 allows you to upload a configuration file to import multiple data sources. Perform the following steps:
On the Data Sources page, click Batch Import.

In the Batch Import panel, click Download Template, and specify the information of the data sources in the file.

Parameter Description Connection Name Required. The name of the connection. The name cannot contain spaces and must be unique. Connection Type Required. Valid values: OceanBase Oracle, OceanBase MySQL, OB Cloud Oracle, OB Cloud MySQL, and OB Sharding MySQL. Host IP Address Required. The IP address of the server where the target database is located.
You can obtain the host IP address from the details page of the tenant in which the target database is located, such as a tenant created on Alibaba Cloud or in OCP.Port Required. The port number of the server where the target database is located.
You can obtain the port number from the details page of the tenant in which the target database is located, such as a tenant created on Alibaba Cloud or in OCP.Cluster Name Optional. The name of the cluster where the target database is located. This parameter is not required for logical databases. Tenant Name Required. The name of the tenant in which the target database is located. This parameter is not required for logical databases.
The tenant name cannot contain spaces.Username Required. An account created in the tenant. In MySQL mode, this account must have the privilege to access the default database. Password The password of the account in the tenant. If the Password parameter is left unspecified, it indicates that the password is an empty string. Environment The environment type. Valid values: dev, sit, and prod. sys tenant account Optional. The account that has the privilege to view the sys tenant views. sys tenant password Optional. The password of the account. Click the file pool in the Batch Import panel to open the file explorer and select the file to be imported. You can also directly drag the file to the file pool to upload it.
Click Import to import the data sources.
You can view the data sources in the data source list.