This topic describes how to connect to and access OceanBase Cloud in the MySQL compatible mode. At present, you can connect to OceanBase Cloud by using a client, GUI, driver, ORM framework, or connection pool.
Clients
When you connect to a MySQL-compatible tenant of OceanBase Cloud, you can use the following clients:
MySQL client (mysql)
mysql is a command-line tool for MySQL databases. You must install it separately. OceanBase Cloud tenants include MySQL-compatible tenants and Oracle-compatible tenants. You can use the mysql client to connect to a MySQL-compatible tenant.
After you connect to a MySQL-compatible tenant of OceanBase Cloud, you can run MySQL O&M commands and SQL statements in the mysql command-line environment to perform the following operations:
Calculate, store, and print the query results.
Create database objects, check and modify object definitions.
Manage databases and modify parameters.
For more information about how to connect to a MySQL-compatible tenant of OceanBase Cloud by using a MySQL client, see Connect to OceanBase Cloud by using a MySQL client.
OceanBase Developer Center (ODC)
OceanBase Developer Center (ODC) is an enterprise-level database development platform designed specifically for OceanBase Database.
ODC supports connecting to MySQL-compatible tenants and Oracle-compatible tenants of transactional instances of OceanBase Cloud. It also provides database developers with features such as daily database development, WebSQL, SQL diagnostics, session management, and data import and export.
For more information about how to connect to OceanBase Cloud by using OceanBase Developer Center, see Connect to OceanBase Cloud by using Client ODC.
GUIs
DBeaver
DBeaver is a general-purpose database client tool that uses JDBC drivers provided by various databases to connect to databases. It supports common relational databases, non-relational databases, and distributed databases. For more information about how to connect to OceanBase Cloud by using DBeaver, see Connect to OceanBase Cloud in DBeaver.
Navicat
Like DBeaver, Navicat is a general-purpose database client tool that uses JDBC drivers provided by various databases to connect to databases. It supports common relational databases, non-relational databases, and distributed databases. For more information about how to connect to OceanBase Cloud by using Navicat, see Connect to OceanBase Cloud in Navicat.
Drivers
When you connect to a MySQL-compatible tenant of OceanBase Database, the following drivers are supported:
Java driver (MySQL Connector/J)
MySQL Connector/J is a JDBC driver provided by MySQL.
Note
Based on the experience with OceanBase Database, we recommend that you use the following versions of MySQL Connector/J:
- For MySQL Connector/J 5.x, we recommend that you use versions between 5.1.40 and 5.1.49.
- For MySQL Connector/J 8.x, we recommend that you use versions between 8.0.7 and 8.0.25, and between 8.2.0 and 8.4.0.
For more information about how to connect to OceanBase Cloud using a Java application, see Connect to OceanBase Cloud using MySQL Connector/J.
C driver (OceanBase Connector/C)
OceanBase Connector/C is a C/C++ client development component for OceanBase Database that supports the C API library.
OceanBase Connector/C allows C/C++ programs to access distributed OceanBase clusters at a lower level for database connections, 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 the network. Client programs reference C API header files during compilation and can connect to C API library files.
Note
The generated
libobclient.sofile for LibOBClient corresponds to thelibmysqlclient.sofile for MySQL. After installing OceanBase Database, the command-line tool is OBClient, which corresponds to the MySQL command-line tool.For more information about how to connect to OceanBase Cloud using a C application, see Connect to OceanBase Cloud using MySQL Connector/C.
Python driver (PyMySQL)
PyMySQL is a library for connecting to MySQL servers in Python 3.x. It follows the Python Database API Specification 2.0 and includes a pure-Python MySQL client library. In the MySQL compatible mode, you can use PyMySQL to connect Python applications to OceanBase Cloud.
For more information about how to connect to OceanBase Cloud using a Python application, see Connect to OceanBase Cloud by using PyMySQL.
Golang driver (Go-SQL-Driver/MySQL)
Go-SQL-Driver/MySQL is a MySQL driver implemented in Go. It follows the Go database/sql standard interface and can be easily integrated with Go applications.
For more information about how to connect to OceanBase Cloud using a Go-SQL-Driver/MySQL application, see Connect to OceanBase Cloud using Go-SQL-Driver/MySQL.
PHP drivers
EXT
EXT (PHP Extension) is a PHP extension for connecting to and interacting with different databases. It provides various features to help developers better manage databases and process data.
For more information about how to connect to OceanBase Cloud using EXT, see EXT driver sample program for connecting to OceanBase Cloud.
MySQLi
MySQLi (MySQL Improved) is an extension provided by PHP for interacting with MySQL databases. It supports both object-oriented and procedural programming, and features prepared statements, transaction support, and multi-query execution to enhance performance and security.
For more information about how to connect to OceanBase Cloud using MySQLi, see MySQLi driver sample program for connecting to OceanBase Cloud.
PDO
PDO (PHP Data Objects) is a database access abstraction layer that allows developers to interact with multiple databases using a consistent approach. PDO supports prepared statements, enhancing security and facilitating easier migration of code between different databases.
For more information about how to connect to OceanBase Cloud by using PDO, see PDO driver sample program for connecting to OceanBase Cloud.
ORM frameworks
Object Relational Mapping (ORM) is a program technology that is used to convert data between different types of systems in an object-oriented programming language. In effect, it creates a "virtual object database" that can be used in the programming language.
When you connect to a MySQL compatible mode tenant of OceanBase Cloud, the following ORM frameworks are supported:
Spring Boot
For more information about how to connect to OceanBase Database by using Spring Boot, see Connect to OceanBase Cloud by using Spring Boot.
Spring Batch
For more information about how to connect to OceanBase Database by using Spring Batch, see Connect to OceanBase Cloud by using Spring Batch.
Spring JDBC
For more information about how to connect to OceanBase Database by using Spring JDBC, see Connect to OceanBase Cloud 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 Cloud by using Spring Data JPA.
Hibernate
For more information about how to connect to OceanBase Database by using Hibernate, see Connect to OceanBase Cloud by using Hibernate.
MyBatis
For more information about how to connect to OceanBase Database by using MyBatis, see Connect to OceanBase Cloud by using MyBatis.
Connection pools
Configuring a database connection pool is an important step to ensure efficient and stable connections between the system and the database. A well-configured connection pool can effectively manage the number of database connections, preventing connection exhaustion in high-concurrency scenarios. It can also timely clear invalid connections through proper timeout settings, ensuring system performance.
OceanBase Cloud supports various connection pools. You can select one based on your business needs.