To use a MySQL tenant of OceanBase, you can use a MySQL client to connect to the tenant.
Procedure:
Open a command-line (CLI) terminal and make sure that the environment variable PATH contains the directory where the MySQL client command is located.
Specify the operating parameters to execute MySQL queries in the following format:
$mysql -h192.168.0.0 -uroot@obmysql#obdemo -P2883 -p**1*** -c -A oceanbase
Note
-h: Specifies the IP address for connecting to OceanBase, which is usually the IP address of the OBProxy.
-u: Specifies the connection account of the tenant. Supported formats: User name@Tenant name#Cluster name or Cluster name:Tenant name:User name. The default username of the administrator of a MySQL tenant is root.
-P: Specifies the OceanBase Database connection port, which is also the listening port of 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: Indicates that the statistical information is not automatically retrieved when connecting to a MySQL tenant.
oceanbase: The name of the database to be accessed. You can change it to a business database.
- After the connection is established, the following command-line prompt is displayed by default:
MySQL [oceanbase]>
- To exit the OceanBase CLI terminal, enter exit and press Enter, or press Ctrl+D.
The following example shows how a MySQL tenant is connected to OceanBase through 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 (0.00 sec)
MySQL [oceanbase]> exit
Bye