一、环境
centos7.6
二、安装unixodbc
yum -y install unixODBC unixODBC-devel
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
三、support MYSQL and PG
step1:
yum -y install mysql-connector-odbc # 下载并链接动态链接库
yum -y install postgresql-odbc
step2:
vim /etc/odbc.ini # 规定驱动名称及对应的动态链接库
[MySQL] # 驱动名称
Description = ODBC for MySQL
Driver = /usr/lib/libmyodbc5.so
Setup = /usr/lib/libodbcmyS.so
Driver64 = /usr/lib64/libmyodbc5.so # 动态链接库位置
Setup64 = /usr/lib64/libodbcmyS.so
FileUsage = 1
[PostgreSQL]
Description = ODBC for PostgreSQL
Driver = /usr/lib/psqlodbcw.so
Setup = /usr/lib/libodbcpsqlS.so
Driver64 = /usr/lib64/psqlodbcw.so
Setup64 = /usr/lib64/libodbcpsqlS.so
FileUsage = 1
step3:
vim /etc/odbcinst.ini # 规定数据源名称及对应的驱动名称和连接信息
[MYSQL_xxx] # 数据源名称
Driver=MYSQL # 驱动名称
SERVER=
USER=
PASSWORD=
PORT=
DATABASE=
[PG_xxx]
Driver=PostgreSQL
SERVERNAME=
USERNAME=
PASSWORD=
PORT=
DATABASE=
step4:
isql -v MYSQL_xxx # 数据源名称
isql -v PG_xxx
四、support DB2
step1:
https://www.ibm.com/support/fixcentral
下载相应补丁DSClients-linuxx64-odbc_cli-10.5.0.11-FP011
tar -zxvf v10.5fp11_linuxx64_odbc_cli.tar.gz
mv odbc_cli_driver /opt/dsdriver
step2:
vim /etc/odbcinst.ini
[DB2]
Description = ODBC for DB2
Driver64 = /opt/dsdriver/odbc_cli_driver/linuxamd64/clidriver/lib/libdb2.so
FileUsage = 1
vim /opt/dsdriver/odbc_cli_driver/linuxamd64/clidriver/cfg/db2cli.ini
[DB2_XXX]
Protocol=TCPIP4
Port=
Database=
Hostname=
UID=
PWD=
autocommit=0
step3:
vim /etc/odbc.ini
[DB2_XXX]
Driver=DB2
step4:
isql -v DB2_XXX
原文链接:https://blog.csdn.net/tttttzz/article/details/127108491