This topic describes how to connect to OceanBase Database by using Unix ODBC.
Install dependencies
yum install unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel
yum install mysql-connector-odbc -y
Check whether the installation is successful.
$odbcinst -j
unixODBC 2.3.1
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/wangzelin.wzl/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
Configure driver-related files and name the OceanBase driver
$sudo vim /etc/odbcinst.ini
# Driver from the mysql-connector-odbc package
# Setup from the unixODBC package
[OceanBase]
Description = ODBC for OceanBase
Driver64 = /usr/lib64/libmyodbc5.so
Setup64 = /usr/lib64/libodbcmyS.so
FileUsage = 1
Check the configured driver
$odbcinst -q -d
[PostgreSQL]
[MySQL]
[OceanBase]
Configure a data source
$sudo vim /etc/odbc.ini
[ob_db]
Description = Data source OceanBase
Driver = OceanBase
Server = 127.0.0.1
Database = testdb
Port = 2881
User = root
Password = ******
CHARSET = UTF8
Check whether encryption is enabled as expected
$isql -v ob_db
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> show tables;
+---------------------------------------+
| Tables_in_testdb |
+---------------------------------------+
| cities |
+---------------------------------------+
SQLRowCount returns 1
1 rows fetched