All Products
Search
Document Center

ApsaraDB for OceanBase:Connect to an OceanBase Database tenant by using OBClient

Last Updated:Aug 01, 2023

OceanBase Client (OBClient) is a CLI tool dedicated to OceanBase Database. You can use it to connect to two types of OceanBase Database tenants: MySQL tenants and Oracle tenants. This topic describes the prerequisites and connection procedure.

Prerequisites

The OBClient application is downloaded and installed. If the OBClient application is not installed, visit Software Center to download and install the corresponding version of OBClient.

Procedure

  1. In the command line, specify the operating parameters of OBClient in the following format:

    $ obclient -hxxx.xxx.xxx.xxx -P3306 -u a**** -p****** -A

    Options:

    Option

    Description

    -h

    The domain name of the OceanBase database to be connected.

    -P

    The port for connecting to the OceanBase database. By default, the port is 1521 in Oracle mode.

    -u

    The tenant account.

    -p

    The account password. For security reasons, you can skip this option. In this case, you will be prompted to enter a password later. The password is invisible.

    -A

    Specifies not to retrieve the information of all tables to ensure a quick logon when you connect to OceanBase Database.

  2. After the connection is created, the following default OBClient command-line prompt appears on the command-line terminal:

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

Examples

  1. Use the Oracle client to connect to an Oracle tenant of OceanBase:

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

    Upon successful logon, the following results are 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. Check the system time.

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

    Returned result:

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

    obclient [a****]> exit

    Execution results:

    Bye

References

For more information about how to use OBClient to connect to an Oracle tenant of OceanBase, see Connect to an OceanBase Database tenant by using OBClient.