All Products
Search
Document Center

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

Last Updated:Dec 12, 2023

OBClient is a CLI tool dedicated to OceanBase Database. You can use it to connect to MySQL tenants and Oracle tenants of OceanBase Database. 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 parameters of OBClient in the following format:

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

    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 3306 in MySQL 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.

    -c

    Specifies not to ignore comments in the runtime environment of MySQL.

    -D

    The name of the database to be accessed. You can change it to the corresponding business database.

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

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

Example

  1. Connect to a MySQL tenant of OceanBase Database by using OBClient

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

    Upon successful logon, the following results are returned:

    Welcome to the OceanBase.  Commands end with ; or \g.
    Your OceanBase connection id is 117093
    Server version: OceanBase 3.2.4.2 (…) (Built Feb 27 2023 17:31:19)
    
    <Omitted>
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    obclient [oceanbase]> 
  2. View the database.

    obclient [oceanbase]> SHOW DATABASES;

    Return result:

    +--------------------+
    | Database           |
    +--------------------+
    | oceanbase          |
    | information_schema |
    | mysql              |
    | rainoon            |
    +--------------------+
    4 rows in set
    Bye
  3. Enter exit and press Enter to exit.

    obclient [oceanbase]> exit

    Execution results:

    Bye