All Products
Search
Document Center

:Connect to OceanBase Database by using a MySQL client

Last Updated:Mar 17, 2023

You can use a MySQL client to connect to a MySQL tenant of OceanBase Database. This topic describes the prerequisites and connection procedure.

Prerequisites

  • The MySQL client is installed locally. OceanBase Database supports the following MySQL client versions: 5.5, 5.6, and 5.7.

  • The environment variable PATH contains the directory where the MySQL client is located.

Procedure

  1. Open a command-line terminal.

  2. Enter the operating parameters of MySQL in the following format:

$mysql -h192.168.0.0 -u -P3306 -p**1*** -c -A oceanbase
Note

Parameters

  • -h: specifies the IP address for connecting to OceanBase Database.

  • -u: specifies the tenant account.

  • -P: specifies the OceanBase Database connection port. The default value is 3306.

  • -p: specifies the account password. For security reasons, you do not need to specify this parameter. In that case, you will be prompted to enter a password later. The password is invisible.

  • -c: specifies that comments must not be ignored in the runtime environment of MySQL.

  • -A: specifies not to automatically retrieve the statistical information when connecting to a MySQL tenant.

  • oceanbase: specifies the name of the database to be accessed. You can change it to the name of the corresponding business database.

  1. After successful connection, the following default OceanBase command-line prompt appears on the command-line terminal:

MySQL [oceanbase]> 
  1. To exit the OBClient command-line terminal, enter exit and press Enter, or press Ctrl+D.

Examples

The following sample code shows how to connect to a MySQL tenant of OceanBase Database from the MySQL client:

$mysql -h192.168.0.0 -u -P3306 -p**1*** -c -A oceanbase
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 62488
Server version: 5.6.25 OceanBase 2.2.20 (…) (Built Aug 10 2019 15:27:33)

<... Omitted…>

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [oceanbase]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| oceanbase          |
| information_schema |
| mysql              |
| test               |
+--------------------+
4 rows in set

MySQL [oceanbase]> exit
Bye