This topic describes the prerequisites and procedure for connecting to an Oracle tenant of OceanBase Database by using OBClient.
Prerequisites
The OBClient application is downloaded and installed. To obtain the OBClient application, contact OceanBase Technical Support or click the link below:
Before you connect to a tenant from a client, make sure that the client is in the allowlist of the tenant. For more information about how to query and configure a tenant allowlist, see Set and view the tenant allowlist.
Procedure
Open a command shell.
Connect to OceanBase Database.
You can connect to OceanBase Database directly or by using an OBProxy.
To connect to the Oracle tenant by using an OBProxy, run the following command:
obclient -h10.10.10.1 -uusername@obtenant#obdemo -P2883 -p****** -c -A oceanbaseor
obclient -h10.10.10.1 -uobdemo:obtenant:username -P2883 -p****** -c -A oceanbaseParameters
-h: the IP address for connecting to OceanBase Database, which is usually the IP address of an OBProxy.-u: the tenant account. Two account formats are supported:Username@Tenant name#Cluster nameandCluster name:Tenant name:Username. The default administrator username of an Oracle tenant isSYS.-P: the port for connecting to OceanBase Database, which is also the listening port of the OBProxy. Default value:2883, which can be customized when OBProxy is deployed.-c: specifies that comments must not be ignored in the runtime environment of OBClient.-A: specifies not to automatically retrieve the statistical information when connecting to an Oracle tenant.oceanbase: the name of the database to be accessed. You can change it to a business database.
Example:
obclient -h10.10.10.1 -u*****@obtenant#obdemo -P2883 -p****** -c -A oceanbaseor
obclient -h10.10.10.1 -uobdemo:obtenant:***** -P2883 -p****** -c -A oceanbaseTo directly connect to the MySQL tenant, run the following command:
obclient -h10.10.10.1 -uusername@obtenant -P2881 -p****** -c -A oceanbaseParameters
-h: the IP address for connecting to OceanBase Database, which is usually the IP address of an OBServer node.-u: the tenant account in theUsername@Tenant nameformat. The default administrator username of an Oracle tenant issys.-P: the port for connecting to OceanBase Database. Default value:2881, which can be customized when OceanBase Database is deployed.-p: the account password. For security reasons, you do not need to specify this parameter. In that case, you will be prompted to enter a password later. The password is invisible.-c: specifies that comments must not be ignored in the runtime environment of OBClient.-A: specifies not to automatically retrieve the statistical information when connecting to an Oracle tenant.oceanbase: the name of the database to be accessed. You can change it to a business database.When you use the direct connection method, make sure that the tenant resources are distributed on the OBServer node you specified. Otherwise, you cannot connect to the tenant by using this OBServer node.
Example:
obclient -h10.10.10.1 -u******@obtenant -P2881 -p****** -c -A oceanbase
After the connection is established, the following command-line prompt is displayed by default:
obclient>To exit the OBClient command line, enter
exitand press Enter, or press the shortcut key Ctrl + D.
Examples
Connect to an Oracle tenant of OceanBase Database by using OBClient:
$obclient -h10.10.10.1 -u******@t_oracle0_91#obdoc -P2883 -p****** -c -A sys
Welcome to the OceanBase. Commands end with ; or \g.
Your OceanBase connection id is 3221686103
Server version: OceanBase 4.0.0.0 (r100000302022111120-7cef93737c5cd03331b5f29130c6e80ac950d33b) (Built Nov 11 2022 20:38:33)
Copyright (c) 2000, 2018, OceanBase and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient> SELECT SYSDATE FROM dual;
+-----------+
| SYSDATE |
+-----------+
| 28-SEP-22 |
+-----------+
1 row in set
obclient> exit
Bye
More information
For information about how to connect to a MySQL tenant of OceanBase Database by using OBClient, see Connect to an OceanBase Database tenant by using OBClient.