OceanBase Client (OBClient) is an interactive batch query tool. You can use it to connect to MySQL and Oracle tenants of OceanBase Database.
Prerequisites
The OBClient application is downloaded and installed. You can click the link below to download the OBClient application:
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 line.
Connect to OceanBase Database.
You can connect to OceanBase Database directly or connect to it by using an OceanBase Database Proxy (ODP).
To connect to OceanBase Database by using an ODP, run the following command:
obclient -h10.10.10.1 -uusername@obtenant#obdemo -P2883 -ppassword -c -A oceanbaseor
obclient -h10.10.10.1 -uobdemo:obtenant:username -P2883 -ppassword -c -A oceanbaseThe parameters are described as follows:
-h: specifies the IP address for connecting to OceanBase Database, which is usually the IP address of an ODP.-u: specifies the tenant account. Two account formats are supported:Username@Tenant name#Cluster nameandCluster name:Tenant name:Username. The default username of the administrator of a MySQL tenant isroot, and that of an Oracle tenant isSYS.-P: specifies the port for connecting to OceanBase Database, which is also the listening port of the ODP. Default value: 2883, which can be customized.-c: specifies that comments must not be ignored in the runtime environment of MySQL.-A: specifies not to automatically retrieve the statistical information when connecting to a MySQL tenant.oceanbase: the name of the database to be accessed. You can change it to a business database.
Here is an 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 OceanBase Database, run the following command:
obclient -h10.10.10.1 -uusername@obtenant -P2881 -ppassword -c -A oceanbaseThe parameters are described as follows:
-h: specifies the IP address for connecting to OceanBase Database, which is usually the IP address of an OBServer node.-u: specifies the tenant account in theUsername@Tenant nameformat. The default username of the administrator of a MySQL tenant isroot, and that of an Oracle tenant isSYS.-P: specifies the port for connecting to OceanBase Database. Default value: 2881, which can be customized.-p: specifies 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 MySQL.-A: specifies not to automatically retrieve the statistical information when connecting to a MySQL 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.
Here is an 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 a MySQL tenant of OceanBase Database by using OBClient:
$obclient -h10.10.10.1 -u******@obmysql#obdemo -P2883 -p****** -c -A sys Welcome to the OceanBase monitor. Commands end with ; or \g. Your OceanBase connection id is 127778 Server version: 5.6.25 OceanBase 3.2.0 (...) (Built Jun 19 2021 11:36:47) <Omitted> Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient> SELECT SYSDATE() FROM dual; +---------------------+ | SYSDATE() | +---------------------+ | 2021-06-29 15:31:50 | +---------------------+ 1 row in set obclient> exit ByeConnect 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 monitor. Commands end with ; or \g. Your OceanBase connection id is 3221576024 Server version: 5.7.25 OceanBase 3.2.0 (...) (Built Jun 18 2021 15:39:59) <Omitted> Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient> SELECT SYSDATE FROM dual; +-----------+ | SYSDATE | +-----------+ | 29-JUN-21 | +-----------+ 1 row in set (0.00 sec) obclient> exit Bye