You can connect to OceanBase Cloud using the MySQL client. This section describes the prerequisites, procedure, and an example for this connection method.
Prerequisites
Before connecting to the database using the MySQL client, confirm the following information:
Ensure the MySQL client is correctly installed locally. The current version of OceanBase Database supports MySQL client versions V5.5, V5.6, and V5.7.
Ensure the environment variable
PATHincludes the directory where the MySQL client commands are located.Have obtained the connection string for the target tenant in MySQL mode under the OceanBase Cloud instance. For instructions, see Get a connection string.
Procedure
Open a command-line terminal locally.
Based on the connection string obtained in the prerequisites, execute the following command to connect to the target tenant in MySQL mode under the OceanBase Cloud instance.
mysql -h ********.oceanbase.cloud -P 3306 -u ***** -D ***** -pParameter description:
-h: The connection address of the OceanBase Cloud database.-P: The connection port of the OceanBase Cloud database.-u: The name of the database account.-D: The name of the database to be accessed.-p: The account password.Note
For security, specify `-p` without a password value and enter the password when prompted. This keeps the password out of command-line arguments and shell history.
Example output:
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 command line, type
exitand press Enter, or use the shortcut key Ctrl + D.
More information
If you encounter issues while connecting to OceanBase Cloud using the MySQL client, we recommend consulting the official MySQL client documentation.