OceanBase Developer Center (ODC) allows you to connect to a MySQL tenant of OceanBase Database. This topic describes how to connect to OceanBase Database by using ODC.
Prerequisites
You have deployed ODC and obtained the URL of Web ODC. For more information about how to deploy ODC, see Deployment of ODC.
Procedure
This topic provides an example of creating a private connection by using Web ODC. The procedure is as follows:
On the login page of ODC, enter your registered account, the password, and the verification code, and then click Log On.
On the Private Connections tab of the homepage, click Create Connection in the upper-right corner to create a private connection.
Note
When you run ODC for the first time, the loading time may take a bit longer than usual.
Specify the following parameters on the Create Connection tab. If you have an OceanBase Database connection string, which 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>', you can obtain the information from the string. You can also paste the string in the field of Intelligent Parsing in the dialog box to automatically populate these parameters.Parameter Description Database Type Select Physical Database or Logical Database. - Physical Database: regular databases.
- Logical Database: ODP (Sharding).
Region Select Independent Deployment/ApsaraStack as the region for the connection example. Connection Name Specify the name of the connection. Set Tag You can add some descriptive information for the connection.
Click the Set Tag button next to Connection Name to set a tag for the current connection. You can set and manage tags in the drop-down list that appears.- Tag setting: Select a tag from the drop-down list. Create tags first if the list is empty.
- Tag management: Click Create Tag at the bottom of the list or the settings icon above the list to go to the Tags page, where you can edit or delete created tags. You can also click Create Tag to set a name or color for the new tag.
Intelligent Parsing You can paste a connection string to the text box. ODC automatically identifies the string and fills in the corresponding values. Connection Mode Select MySQL. Logical databases support 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).
Database Account - Database Username: the username of an account created in the tenant. In the MySQL mode of OceanBase Database, 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 box to test whether you can connect to the target database.
- Save Password: If you deselect this option, the database password for the connection is not saved, and you must enter the database password in the password dialog box each time you use or test the connection. If you select this option, the database password for the connection is saved, and you do not need to enter the database password each time you use the connection.
Note
- An error will be returned if the configurations such as the username, password, and network settings are invalid.
- You can only connect to a database in the current tenant. Otherwise, a test failure error will be returned.
- In ODC V4.0.0 and later, you can save the connection without entering the database account and password.
Default Database/Schema (Optional) When you connect to a MySQL tenant of OceanBase Database, you must specify the default database for the connection. Note
If you leave this parameter unspecified in the MySQL mode of OceanBase Database, the
information_schemadatabase is connected by default. However, if the connection to theinformation_schemadatabase fails, you need to specify a database that can be accessed by the current user.SQL Query Timeout Value You can specify a timeout value for SQL queries. A query whose execution time exceeds the timeout value is automatically terminated. The default timeout value is 60 seconds. 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 Database Type is set to Physical Database, you can specify an account that has the privilege to querysystenant views, and the password. The account and password are automatically populated when sys is specified as the tenant in Endpoint.- Account: an account that has the privilege to query the views under the
systenant. - Password: the password of the account.
Note
- In ODC V2.3.0 and later, to use the import and export features, you need to configure the
root@sysaccount in the Advanced Configuration section when you create a connection. - In ODC V2.4.1 and later, the strong dependency on the
root@sysaccount is removed when you query views for import or export. If theroot@sysaccount is not configured, some ODC objects such as stored procedures and functions do not support the export feature. If theroot@sysaccount is configured, you can access the views under thesystenant to obtain the optimal data routing strategy, which can increase the export speed. - The account and password of the
systenant are the account and password of a user in a tenant of the cluster. Do not enter@sys#clusterin the Account parameter. For example, the account can beroot.
Click Save to save the current configuration in the ODC connection list. When you log in to ODC the next time, you can directly select the connection from the list. The connection configuration does not necessarily need to pass the connection test when you save the configuration.
Note
Before you save the configuration, 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.
References
For more information about other features of ODC, see the ODC documentation in OceanBase Documentation Center.