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******@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: User name@Tenant name#Cluster name or Cluster name:Tenant name:User name. The default administrator username of an Oracle tenant is "SYS".
-P: Specifies the port for connecting to OceanBase Database, which is also the listening port of OBProxy. The default value is 2883. You can customize the value as required. If you directly connect to an OBserver instead of connecting to OceanBase through OBProxy (without specifying "#Cluster name" in the -u parameter), the default value is 2881.
-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.
Example
Use 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 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 from dual;
+---------------------+
| SYSDATE |
+---------------------+
| 2020-04-01 21:53:22 |
+---------------------+
1 row in set (0.00 sec)
obclient> exit
Bye