linux 连接ms sql server 2008 需要安装freetds,最新版本官网下载ftp://ftp.freetds.org/pub/freetds/stable/freetds-patched.tar.gz
安装解压 tar xzvf freetds-patched.tar.gz
./configure --prefix=/usr/local/freetds --with-tdsver=7.3 --enable-msdblib
make && make install
增加路径 export PATH=/usr/local/freetds/bin:$PATH
查看版本 tsql -C
测试 tsql -H ip -p 1433 -U user -P pass
locale is "zh_CN.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> ^C
出现上面提示表示成功。
测试中遇到 sql server 2008 配置工具中开启了加密,连接会失败报错如下:
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
取消后正常
完成后再装pyodbc 之类就可以用python 连接了