This topic describes how to connect to OceanBase Cloud by using a MySQL client. This topic describes the prerequisites and connection procedure.
Prerequisites
Before you connect to OceanBase Cloud by using a MySQL client, make sure that the following conditions are met:
A MySQL client is installed on your server. OceanBase Cloud supports MySQL clients of the following versions: 5.5, 5.6, and 5.7.
The environment variable
PATHcontains the directory where the MySQL client is located.You have obtained the connection string of the target MySQL-compatible tenant in an OceanBase Cloud instance. For more information, see Obtain the connection string.
Procedure
Open a command shell locally.
Run the following command to connect to the target MySQL-compatible tenant in the OceanBase Cloud instance based on the obtained connection string mentioned in the "Prerequisites" section.
mysql -h ********.oceanbase.cloud -P 3306 -u ***** -D ***** -pThe parameters are described as follows:
-h: the access address of OceanBase Cloud.-P: the access port of OceanBase Cloud.-u: the username of the database account.-D: the name of the database to be accessed.-p: the password of the account.Note
For security purposes, we recommend that you do not directly enter the password on the CLI, especially in an environment where the script or historical records are visible. You can skip this option and enter the password when being prompted to.
The return result is as follows:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 524370 Server version: 5.6.25 OceanBase 4.2.4.0 (r100000252024070621-b9f4bc37bbc6249f5b77e68a9338eaacf3787197) (Built Jul 6 2024 22:10:15) <...> Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>To exit the MySQL client, enter
exitand press Enter, or press the keyboard shortcut Ctrl + D.
More information
If errors occur when you connect to OceanBase Cloud by using a MySQL client, we recommend that you refer to the official MySQL documentation.