前言
主要测试通过ODBC方式来连接Doris 数据
一、环境
1、Cntos7
1、Doris 2.0.2
2、Mysql-connector-odbc-5.3.7
二、使用步骤
1.安装 odbc驱动
Mysql ODBC驱动下载地址 https://downloads.mysql.com/archives/c-odbc/
1、下载
这里我们下载的是RPM安装包 mysql-connector-odbc-5.3.7-1.el7.x86_64.rpm
2、安装 执行以下命令
yum localinstall -y mysql-connector-odbc-5.3.7-1.el7.x86_64.rpm
3、查看版本
odbcinst -j
[root@129 etc]# odbcinst -j
unixODBC 2.3.1
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
2.配置odbc驱动
1、编辑 /etc/odbcinst.ini
[MySQL]
Description=ODBC for MySQL
Driver=/usr/lib64/libmyodbc5a.so
Setup=/usr/lib64/libodbcmyS.so
Driver64=/usr/lib64/libmyodbc5a.so
Setup64=/usr/lib64/libodbcmyS.so
FileUsage=1
[MySQL ODBC 5.3 Unicode Driver]
Driver=/usr/lib64/libmyodbc5w.so
UsageCount=1
[MySQL ODBC 5.3 ANSI Driver]
Driver=/usr/lib64/libmyodbc5a.so
UsageCount=1
2、编辑 /etc/odbc.ini
这里的 Driver 对应的 /etc/odbcinst.ini 里面配置的 Driver 驱动
这里需要注意的是charset ,这里默认的字符集是latin1 需要改为UTF8
[doris]
Description = MySQL connection to 'asterisk' database
Driver = MySQL ODBC 5.3 ANSI Driver
Database = streamload
Server = 192.168.31.129
UserName = root
Password = root
Port = 9030
charset = UTF8
3、测试ODBC连接
[root@129 etc]# isql -v doris
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL> select * from r2;
+-----------+--------------------------------------------------------------------------
| id | name | age | address | create_date | rowkey |
+-----------+--------------------------------------------------------------------------
| 2 | name | 23.12 | address | 2023-11-03 00:00:00| row11 |
| 2 | name | 23.12 | address | 2023-11-03 00:00:00| row11 |
+-----------+--------------------------------------------------------------------------
SQLRowCount returns 2
2 rows fetched
SQL>
标签:ODBC,数据库,MySQL,odbc,etc,Driver,lib64,Doris
From: https://www.cnblogs.com/yanzhong/p/17823596.html