OceanBase Client (OBClient) is a command-line client for OceanBase. It enables you to connect to MySQL and Oracle tenants of OceanBase.
Procedure:
Open a command-line terminal.
Specify parameters for OBClient in the following format:
$ obclient -h10.0.0.0 -u**u***@t_oracle0_91#obdoc -P2883 -p**1*** -c -A sys
Note
-h: Specifies an IP address to connect to OceanBase Database, which is usually an OBProxy address.
-u: Specifies the connection account of the tenant. Supported formats: username@tenant_name#cluster_name or cluster_name:tenant_name:username.The default administrator username of Oracle tenants is "sys".
-P: Specifies the port for connecting to OceanBase, which is also the listening port of OBProxy. The default value is 2883. 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: Sends comments in SQL statements to the database.
-A: Specifies that OceanBase Database does not obtain all table information when you connect to the database to ensure the fastest logon.
sys: The name of the database to be accessed. You can change it to a business database.
- After the connection is established, the following command-line prompt is displayed by default:
obclient>
To exit the OceanBase CLI terminal, enter exit and press Enter, or press Ctrl+D.
The following example shows how to connect to an Oracle tenant of OceanBase through OBClient.
$obclient -h10.0.0.0 -u**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 64621
Server version: 5.6.25 OceanBase 2.2.20 (...) (Built Aug 10 2019 15:27:33)
<Omitted>
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
obclient> select sysdate();
+---------------------+
| sysdate() |
+---------------------+
| 2020-04-01 21:53:22 |
+---------------------+
1 row in set (0.00 sec)
obclient> exit
Bye