OBClient is the dedicated command-line interface for OceanBase databases. You can use it to connect to tenants in MySQL and Oracle modes. This topic describes the prerequisites and procedure for connecting.
Prerequisites
Ensure that you have downloaded and installed the OBClient application. If you have not, visit the Software Center to download the appropriate version of OBClient (OceanBase command-line client).
Procedure
Enter the OBClient runtime parameters on the command line. See the following example for the format.
$ obclient -hxxx.xxx.xxx.xxx -P3306 -u a**** -p****** -AParameters:
Parameter
Description
-h
Specifies the domain name for the OceanBase database connection.
-P
Specifies the port for the OceanBase database connection. The default port for an Oracle mode tenant is 1521.
-u
Specifies the logon account for the tenant.
-p
Specifies the account password. For security, omit this parameter and enter the password when prompted. The password is not displayed.
-A
Skips retrieving all table information upon connection for a faster logon.
After you successfully connect, the default OBClient command-line prompt appears, as shown in the following example:
obclient [a****]>To exit the OBClient command line, enter
exitand press Enter, or use the keyboard shortcutCtrl + D.
Examples
Connect to an Oracle tenant of OceanBase using OBClient.
$ obclient -hxxx.xxx.xxx.xxx -P1521 -ua**** -p****** -AAfter a successful logon, the following output is returned:
Welcome to the OceanBase. Commands end with ; or \g. Your OceanBase connection id is 102073 Server version: OceanBase 3.2.4.2 (…) (Built Feb 27 2023 17:31:19) 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.View the system time.
obclient [a****]> SELECT SYSDATE FROM dual;The following output is returned:
+-----------+ | SYSDATE | +-----------+ | 29-MAR-23 | +-----------+ 1 row in setEnter
exitand press Enter to exit.obclient [a****]> exitThe following output is returned:
Bye
References
For an example of connecting to a MySQL tenant of an OceanBase database, see Connect to an OceanBase tenant using OBClient.