This topic describes the methods for connecting to OceanBase Database in MySQL mode. You can connect to OceanBase Database by using a client, a driver, or an object-relational mapping (ORM) framework.
Connect to OceanBase Database by using a client
You can connect to a MySQL tenant of OceanBase Database by using any of the following clients:
mysql client
mysql is a MySQL command-line interface (CLI) tool that must be separately installed. OceanBase Database tenants include MySQL tenants and Oracle tenants. You can use the mysql client to access a MySQL tenant.
After you connect to OceanBase Database, you can run MySQL O&M commands and execute SQL statements in the CLI of the mysql client for the following purposes:
Calculating, storing, and generating query results
Creating database objects and checking and modifying object definitions
Managing databases and modifying parameters
For more information about how to connect to a MySQL tenant of OceanBase Database by using the mysql client, see Connect to an OceanBase Database tenant by using the mysql client.
OBClient
OBClient is an interactive query tool that supports batch processing. It must be installed separately. OBClient provides a CLI and acts as the client when it is connected to OceanBase Database. It supports MySQL and Oracle tenants of OceanBase Database.
Before you use OBClient to connect to an OceanBase Database tenant, you must specify the connection information of the tenant. After you connect to OceanBase Database, you can use OBClient to run some database commands, including general MySQL commands, and execute some SQL and PL/SQL statements for the following purposes:
Calculating, storing, and generating query results
Creating database objects and checking and modifying object definitions
Developing and running batch processing scripts
Managing databases and modifying parameters
For more information about how to connect to an OceanBase Database tenant by using OBClient, see Connect to an OceanBase Database tenant by using OBClient.
ODC
OceanBase Developer Center (ODC) is an enterprise-level database development platform tailored for OceanBase Database.
ODC is compatible with both MySQL and Oracle tenants in OceanBase Database. It provides database developers with various features, such as daily development, WebSQL-based workspace, SQL diagnostics, session management, and data import and export.
For more information about how to connect to an OceanBase Database tenant by using ODC, see Connect to OceanBase Database by using ODC.
Connect to OceanBase Database by using a driver
You can connect to a MySQL tenant of OceanBase Database by using any of the following drivers:
Java driver (MySQL Connector/J)
MySQL Connector/J is a Java Database Connectivity (JDBC) driver provided by MySQL.
For more information about how to connect Java applications to OceanBase Database, see Build a Java application.
C driver (OceanBase Connector/C)
OceanBase Connector/C is an OBClient development component based on C/C++. OceanBase Connector/C supports C API libraries.
OceanBase Connector/C allows C/C++ applications to access distributed OceanBase clusters from the underlying layer. Then, the applications can perform operations such as database connection, data access, error processing, and prepared statement processing.
OceanBase Connector/C, also known as
libobclient, is used by applications as an independent server process to communicate with OBServers through network connections. A client application references the C API header file during compilation and can connect to the C API library file.Note
The
.sofile generated bylibobclientislibobclient.so, which corresponds to thelibmysqlclient.sofile in MySQL. OceanBase Database uses OBClient as its CLI tool, which corresponds to the CLI tool in MySQL.For more information about how to connect C applications to OceanBase Database, see Build a C application.
Python driver (PyMySQL)
If you use Python 3.x, you can connect to a MySQL database server by using PyMySQL. PyMySQL implements Python Database API Specification 2.0 and contains a pure-Python MySQL client library. In MySQL mode of OceanBase Database, you can use PyMySQL to connect Python applications to OceanBase Database.
For more information about how to connect Python applications to OceanBase Database, see Build a Python application.
Connect to OceanBase Database by using an ORM framework
ORM is a programming technique that converts data between different types of systems in object-oriented programming languages. In effect, ORM actually creates a "virtual object database" that can be used in programming languages.
You can connect to a MySQL tenant of OceanBase Database by using any of the following ORM frameworks:
Spring Boot
For more information about how to connect to OceanBase Database by using Spring Boot, see Connect to OceanBase Database by using Spring Boot.
Spring Batch
For more information about how to connect to OceanBase Database by using Spring Batch, see Connect to OceanBase Database by using Spring Batch.
Spring JDBC
For more information about how to connect to OceanBase Database by using Spring JDBC, see Connect to OceanBase Database by using Spring JDBC.
Hibernate
For more information about how to connect to OceanBase Database by using Hibernate, see Connect to OceanBase Database by using Hibernate.