0%

linux安装unixODBC

linux安装unixODBC

https://blog.csdn.net/u010587433/article/details/46799037 linux下mysql odbc配置

https://lonesysadmin.net/2013/02/22/error-while-loading-shared-libraries-cannot-open-shared-object-file/ 解决方案:Error While Loading Shared Libraries, Cannot Open Shared Object File

下载

http://www.unixodbc.org/ 下载:unixODBC-2.3.7.tar.gz

创建文件夹

创建unixODBC文件夹, 把unixODBC-2.3.7.tar.gz放到之内

cd 到 unixODBC文件夹

解压安装包

解压+进入解压后的文件夹

1
2
tar zxvf unixODBC-2.3.0.tar.gz 
cd unixODBC-2.3.0

安装(要有root权限)

1
2
3
4
su
./configure --prefix=/usr/local/lib --includedir=/usr/include --libdir=/usr/local/lib -bindir=/usr/bin --sysconfdir=/etc
make
make install

检测是否装好

(a) 检查ini文件
(目前ini文件是个空文件; mysql Connector安装后会在此ini文件内有设置)

1
2
3
4
ll /ect/*.ini
结果:
-rw-r--r-- 1 root root 0 Feb 25 22:06 /etc/odbc.ini
-rw-r--r-- 1 root root 0 Feb 25 22:06 /etc/odbcinst.ini

(b)检查library
(都放在/usr/local/lib/: 可能user调用程序时,只能看到/usr/lib/,看不到here)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
ll /usr/local/lib/
结果:
-rwxr-xr-x 1 root root 986 Feb 25 22:06 libodbccr.la*
lrwxrwxrwx 1 root root 18 Feb 25 22:06 libodbccr.so -> libodbccr.so.2.0.0*
lrwxrwxrwx 1 root root 18 Feb 25 22:06 libodbccr.so.2 -> libodbccr.so.2.0.0*
-rwxr-xr-x 1 root root 545952 Feb 25 22:06 libodbccr.so.2.0.0*
-rwxr-xr-x 1 root root 972 Feb 25 22:06 libodbcinst.la*
lrwxrwxrwx 1 root root 20 Feb 25 22:06 libodbcinst.so -> libodbcinst.so.2.0.0*
lrwxrwxrwx 1 root root 20 Feb 25 22:06 libodbcinst.so.2 -> libodbcinst.so.2.0.0*
-rwxr-xr-x 1 root root 636984 Feb 25 22:06 libodbcinst.so.2.0.0*
-rwxr-xr-x 1 root root 948 Feb 25 22:06 libodbc.la*
lrwxrwxrwx 1 root root 16 Feb 25 22:06 libodbc.so -> libodbc.so.2.0.0*
lrwxrwxrwx 1 root root 16 Feb 25 22:06 libodbc.so.2 -> libodbc.so.2.0.0*
-rwxr-xr-x 1 root root 2520848 Feb 25 22:06 libodbc.so.2.0.0*

(c)检查程序bin

1
2
3
4
5
6
7
8
9
ll -rt /usr/bin
结果:
lrwxrwxrwx 1 root root 24 Feb 25 17:05 code -> /usr/share/code/bin/code*
-rwxr-xr-x 1 root root 93952 Feb 25 22:06 isql*
-rwxr-xr-x 1 root root 165376 Feb 25 22:06 dltest*
-rwxr-xr-x 1 root root 112680 Feb 25 22:06 odbcinst*
-rwxr-xr-x 1 root root 77000 Feb 25 22:06 iusql*
-rwxr-xr-x 1 root root 22856 Feb 25 22:06 odbc_config*
-rwxr-xr-x 1 root root 21056 Feb 25 22:06 slencheck*

(d)查看安装信息

1
2
3
odbcinst -j
结果1st:
odbcinst: error while loading shared libraries: libodbcinst.so.2: cannot open shared object file: No such file or directory

分析:
可能是运行odbcinst程序时,load library只看到了/usr/lib;
忽视了放在/usr/local/liblibodbcinst.so.2

解决方案:
/usr/lib内创建链接link of 放在/usr/local/liblibodbcinst.so.2

操作:

1
2
3
4
5
6
7
8
9
10
11
12
ln -s /usr/local/lib/libodbcinst.so.2 /usr/lib/libodbcinst.so.2
ldconfig
odbcinst -j
结果2rd:
unixODBC 2.3.7
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