Connect to an OceanBase tenant using OBClient

更新时间:
复制 MD 格式

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

  1. 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****** -A

    Parameters:

    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.

  2. After you successfully connect, the default OBClient command-line prompt appears, as shown in the following example:

    obclient [a****]>
  3. To exit the OBClient command line, enter exit and press Enter, or use the keyboard shortcut Ctrl + D.

Examples

  1. Connect to an Oracle tenant of OceanBase using OBClient.

    $ obclient -hxxx.xxx.xxx.xxx  -P1521 -ua**** -p****** -A

    After 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.
  2. View the system time.

    obclient [a****]> SELECT SYSDATE FROM dual;

    The following output is returned:

    +-----------+
    | SYSDATE   |
    +-----------+
    | 29-MAR-23 |
    +-----------+
    1 row in set
  3. Enter exit and press Enter to exit.

    obclient [a****]> exit

    The 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.