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
In the command line, specify the parameters of OBClient in the following format:
$ obclient -hxxx.xxx.xxx.xxx -P3306 -u a**** -p****** -c -A -DoceanbaseOptions:
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.
After the connection is created, the following default OBClient command-line prompt appears on the command-line terminal:
obclient [oceanbase]>To exit the OBClient command-line prompt, enter
exitand press Enter, or press Ctrl+D.
Example
Connect to a MySQL tenant of OceanBase Database by using OBClient
$ obclient -hxxx.xxx.xxx.xxx -P3306 -u a**** -p****** -c -A -DoceanbaseUpon 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]>View the database.
obclient [oceanbase]> SHOW DATABASES;Return result:
+--------------------+ | Database | +--------------------+ | oceanbase | | information_schema | | mysql | | rainoon | +--------------------+ 4 rows in set ByeEnter
exitand press Enter to exit.obclient [oceanbase]> exitExecution results:
Bye