This topic describes how to connect to the MySQL mode of OceanBase Database. Currently, 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)
The mysql client is a MySQL command-line interface (CLI) tool that must be separately installed. OceanBase Database supports 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 on the CLI of the mysql client for the following purposes:
Calculating, storing, and generating query results
Creating database objects, 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 tenant by using the mysql client.
OBClient
OceanBase Client (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 in OceanBase Database.
Before you use OBClient to connect to an OceanBase 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, 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 tenant by using OBClient, see Connect to an OceanBase 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 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 a C/C++ based client development component for OceanBase Database. It 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 handling, and prepared statement processing.
OceanBase Connector/C, also known as LibOBClient, is used by applications as an independent server process to communicate with OBServer nodes through network connections. Applications will reference C API header files during compilation and can connect to the C API library files.
Note
The
.sofile generated by LibOBClient islibobclient.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 the 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 for data conversion between a relational database and an object-oriented programming language. This creates, in effect, a "virtual object database" that can be used from within the programming language.
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.
Spring Data JPA
For more information about how to connect to OceanBase Database by using Spring Data JPA, see Connect to OceanBase Database by using Spring Data JPA.
Hibernate
For more information about how to connect to OceanBase Database by using Hibernate, see Connect to OceanBase Database by using Hibernate.
MyBatis
For more information about how to connect to OceanBase Database by using MyBatis, see Connect to OceanBase Database by using MyBatis.