CentOS下安装FreeTDS
导读
官方网站:http://www.freetds.org
下载地址:http://ibiblio.org/pub/linux/alpha/freetds/stable/freetds-stable.tgz
这个软件能够用linux和unix连接ms sqlserver和sybase数据库
安装与配置
-
首先下载freetds安装包到服务器
wget -c http://ibiblio.org/pub/linux/alpha/freetds/stable/freetds-stable.tgz
-
解压
tar -zxvf freetds-stable.tgz
-
编译安装
-
因为是编译安装所以确保机器有安装gcc(可使用yum进行安装)
yum install gcc-c++ yum install ncurses-devel
-
开始安装
cd freetds-0.91/ ./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib make && makeinstall
解释: 安装freetds到目录/usr/local/freetds:--prefix=/usr/local/freetds 支持mssql2000:--with-tdsver=8.0 --enable-msdblib
-
-
freetds默认安装在/usr/local/freetds目录当中,库文件在相应的lib目录下。
vim /etc/ld.so.conf
加入一行/usr/local/freetds/lib
-
然后运行以下指令使更改生效:
ldconfig
-
测试连接
tsql -h mssql服务器服务ip -p 1433 -u mssql服务器登陆帐号 -p mssql服务器登陆密码
$ tsql -h xxxxxx-p 1433 -u sa -p xxxxxx -d test locale is "zh_cn.utf8" locale charset is "utf-8" default database being set to test 1> select @@version 2> go microsoft sql server 2008 r2 (rtm) - 10.50.1600.1 (intel x86) apr 2 2010 15:53:02 copyright (c) microsoft corporation data center edition on windows nt 5.1 <x86> (build 2600: service pack 3) (1 row affected)
问题
adaptive server connection failed
locale is "en_us.utf-8" locale charset is "utf-8" using default charset "utf-8" error 20017 (severity 9): unexpected eof from the server os error 115, "operation now in progress" error 20002 (severity 9): adaptive server connection failed there was a problem connecting to the server
执行
tsql -c
[root@thinkpa freetds-0.91]# tsql -c compile-time settings (established with the "configure" script) version: freetds v0.91 freetds.conf directory: /usr/local/etc ms db-lib source compatibility: no sybase binary compatibility: no thread safety: yes iconv library: yes tds version: 5.0 iodbc: no unixodbc: no sspi "trusted" logins: no kerberos: no
发现freetds的版本是5.0,考虑到可能是freetds版本的问题
两种解决方式:
-
修改全局tds 版本号
找到
/usr/local/etc/freetds.conf
修改[global]
下面的tds version
为8.0
-
连接时修改tds版本号
tdsver=7.0 tsql -h
整个连接命令则变为:
tsql -h mssql服务器服务ip -p 1433 -u mssql服务器登陆帐号 -p mssql服务器登陆密码
adaptive server connection failed
"cannot open server 'xxxxxxx' requested by the login. client with ip address 'xxxxxxxxx' is not allowed to access the server. to enable access, use the windows azure management portal or run sp_set_firewall_rule on the master database to create a firewall rule for this ip address or address range. it may take up to five minutes for this change to take effect." error 20002 (severity 9): adaptive server connection failed
这个毋庸置疑了,找管理员开通白名单再访问吧!
-
下一篇: 几个Promise使用的例子分享
推荐阅读
-
linux下mysql5.7.17最新稳定版本安装教程
-
Mac系统下安装PHP Xdebug
-
windows环境下使用Composer安装ThinkPHP5
-
centos7安装mysql并jdbc测试教程
-
CentOs7.x安装Mysql的详细教程
-
python在Windows下安装setuptools(easy_install工具)步骤详解
-
linux下mysql的安装步骤
-
Centos7安装和配置Mysql5.7
-
windows10下安装TensorFlow Object Detection API的步骤
-
VMware Workstation 11 虚拟机安装Centos 6.6系统图文教程