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 MySQL clients of the following versions: V5.5, V5.6, and V5.7.
The environment variable PATH contains the directory where the MySQL client is located.
Procedure
Open a CLI terminal.
Enter the operating parameters of MySQL in the following format:
$mysql -h192.168.0.0 -uroot@obmysql#obdemo -P2883 -p**1*** -c -A oceanbaseNote
Parameters
- -h: specifies the IP address for connecting to OceanBase Database, which is usually the IP address of an OBProxy.
- -u: specifies a tenant account in the Username@Tenant name#Cluster name or Cluster name:Tenant name:Username format. The default username of the administrator of the MySQL tenant is root.
- -P: specifies the port for connecting to OceanBase Database, which is also the listening port of the OBProxy. Default value: 2883, which can be customized.
- -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.
After the connection is created, the following default OBClient CLI prompt appears on the CLI terminal:
MySQL [oceanbase]>To exit the OceanBase CLI terminal, enter
Exitand press Enter, or press Ctrl+D.
Example
The following sample code shows how to connect to a MySQL tenant of OceanBase Database from a MySQL client:
$mysql -h192.168.0.0 -uroot@obmysql#obdemo -P2883 -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