OceanBase Client (OBClient) is a command-line client tool dedicated to OceanBase Database. You can use it to connect to two types of OceanBase Database tenants: MySQL and Oracle.
Prerequisites
You have obtained the OBClient installation package from the OceanBase technical support team.
Procedure
Open a command-line terminal.
Specify the operating parameters to execute MySQL queries in the following formats:
Connection through an OBProxy:
$obclient -h10.0.0.0 -u******@obmysql#obdemo -P2883 -p**1*** -c -A oceanbaseNote
-h: Specifies the IP address for connecting to OceanBase Database, which is usually the IP address of the OBProxy.
-u: The tenant account. Two account formats are supported:
Username@Tenant name#Cluster nameandCluster name:Tenant name:UsernameThe default username of the administrator of the MySQL tenant is root.-P: Specifies the OceanBase Database connection port, which is also the listening port of OBProxy. The default value is 2883. You can customize the value as required.
-c: Specifies that comments must not be ignored in the runtime environment of MySQL.
-A: Indicates that the statistical information is not automatically retrieved when connecting to a MySQL tenant.
oceanbase: The name of the database to be accessed. You can change it to a business database.
Direct connection:
$obclient -h10.0.0.0 -u******@obmysql -P2881 -p**1*** -c -A oceanbaseNote
-h: The IP address for connecting to OceanBase, which is usually the IP address of an OBServer.
-u: The tenant account. Two account formats are supported:
Username@Tenant nameandTenant name:UsernameThe default username of the administrator of the MySQL tenant is root.-P: Specifies the OceanBase Database connection port. The default value is 2881. You can customize the value as required.
-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: Indicates that the statistical information is not automatically retrieved 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 you specified. Otherwise, you cannot connect to the tenant through this OBServer.
After the connection is established, the following command-line prompt is displayed by default:
obclient>If you want to exit the OceanBase command-line terminal, enter
exitand press Enter, or press the shortcut key Ctrl + D .
Example
Use OBClient to connect to a MySQL tenant of OceanBase Database:
$obclient -h10.0.0.0 -u******@obmysql#obdemo -P2883 -p**1*** -c -A sys obclient: [Warning] Using a password on the command line interface can be insecure. Welcome to the OceanBase monitor. Commands end with ; or \g. Your OceanBase connection id is 3221495183 Server version: 5.7.25 OceanBase 2.2.77 (...) (Built Oct 23 2020 11:00:48) <Omitted> Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient> SELECT SYSDATE() FROM dual; +---------------------+ | SYSDATE() | +---------------------+ | 2020-12-24 13:52:11 | +---------------------+ 1 row in set (0.00 sec) obclient> exit ByeUse OBClient to connect to an Oracle tenant of OceanBase Database:
$obclient -h10.0.0.0 -u******@t_oracle0_91#obdoc -P2883 -p**1*** -c -A sys obclient: [Warning] Using a password on the command line interface can be insecure. Welcome to the OceanBase monitor. Commands end with ; or \g. Your OceanBase connection id is 3221841095 Server version: 5.7.25 OceanBase 2.2.74 (...) (Built Jul 15 2020 21:30:23) <Omitted> Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. obclient> SELECT SYSDATE FROM dual; +-----------+ | SYSDATE | +-----------+ | 24-DEC-20 | +-----------+ 1 row in set (0.01 sec) obclient> exit Bye