linux-mint 下添加 ODBC DRIVER
搬运自https://code.google.com/p/odbc/wiki/InstallingMicrosoftDriverOnDebianLinux,做了些小修改
安装必要的 odbc library
sudo apt-get install libodbc1
下载微软的sql driver for Red Hat 6(Dibian也可以用,只是需要做些调整)
wget http://download.microsoft.com/download/B/C/D/BCDD264C-7517-4B7D-8159-C99FC5535680/RedHat6/msodbcsql-11.0.2270.0.tar.gz
然后进入下载目录解包
$ tar xf msodbc* $ cd msodbc*
由于这个driver是给Red Hat 用的,debian下的一些依赖库就不能被侦测到。需要做一些符号链接来让它找到依赖库的位置
查看缺少的依赖库
$ ldd lib64/libmsodbcsql-11.0.so.2270.0 | grep not
输出应该是
libcrypto.so.10 => not found libssl.so.10 => not found
建立符号链接
$ cd /usr/lib/x86_64-linux-gnu $ sudo apt-get install libssl-dev $ sudo ln -s libssl.so.1.0.0 libssl.so.10 $ sudo ln -s libcrypto.so.1.0.0 libcrypto.so.10
再次重复之前的步骤检查依赖库,应该没有了
之后就是就入安装目录执行自带的安装脚本
$ sudo bash ./install.sh install --force
输出如果是
./install.sh: line 233: rpm: command not found Checking for 64 bit Linux compatible OS ..................................... OK Checking required libs are installed ................................. NOT FOUND unixODBC utilities (odbc_config and odbcinst) installed ............ NOT CHECKED unixODBC Driver Manager version 2.3.0 installed .................... NOT CHECKED unixODBC Driver Manager configuration correct ...................... NOT CHECKED Microsoft ODBC Driver 11 for SQL Server already installed .......... NOT CHECKED Microsoft ODBC Driver 11 for SQL Server files copied ........................ OK Symbolic links for bcp and sqlcmd created ................................... OK Microsoft ODBC Driver 11 for SQL Server registered ................... INSTALLED Install log created at /tmp/msodbcsql.6208.20652.13584/install.log. One or more steps may have an *. See README for more information regarding these steps.
看起来好多问题啊...不过好像没有什么关系
接下来运行
sqlcmd -S localhost
输出应该是
Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : Login timeout expired. Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.. Sqlcmd: Error: Microsoft ODBC Driver 11 for SQL Server : TCP Provider: Error code 0x274D.
说明microsoft library 已经安装完成
接下来创建一个文本文件
[MSSQL] Description = Official native client Driver =/usr/local/lib/libmsodbcsql-11.0.so.2270.0
保存为tds.driver.template2
然后
sudo odbcinst -i -d -f tds.driver.template2 odbcinst: Driver installed. Usage count increased to 1. Target directory is /etc
安装完成
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。