# tar vxzf freetds-0.82.tar.gz
# cd freetds-0.82
# ./configure --prefix=/usr/local/freetds --with-unixodbc=/usr/local/unixODBC --with-tdsver=8.0 --enable-msdblib
# make
# make install
安装DBI前需要安装:
http://search.cpan.org/CPAN/authors/id/M/MS/MSCHWERN/Test-Simple-0.98.tar.gz
http://search.cpan.org/CPAN/authors/id/M/MS/MSCHWERN/ExtUtils-MakeMaker-6.56.tar.gz
否则会报:
Warning: prerequisite ExtUtils::MakeMaker 6.48 not found. We have 6.30.
Warning: prerequisite Test::Simple 0.9 not found. We have 0.62.
Using DBI 1.625 (for perl 5.008008 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/
Using DBI 1.625 (for perl 5.008008 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBI/
Writing Makefile for DBD::ODBC
Warning: not all required environment variables are set.
Warning: Will not be able to run tests as you have not defined
all of DBI_DSN, DBI_USER and DBI_PASS environment variables.
$ tar vxzf DBD-ODBC-1.616.tar.gz
$ cd DBD-ODBC-1.616
$ perl Makefile.PL
$ make
$ make install
测试dbi安装是否成功:
$ perl -e 'use DBI 1.625;'
如果出现"DBI version 1.616 required--this is only version 1.30 at -e line 1."错误,需要更新dbi;
如果出现 "DBI cannot be found in @INC"错误,表明还没有安装
在安装之前要先设置一下环境变量
# export ODBCHOME=/usr/local/unixODBC
#export LD_LIBRARY_PATH=/usr/local/unixODBC/lib
之后开始编译安装
# tar vxzf cd DBD-ODBC-1.43.tar.gz
# cd DBD-ODBC-1.43
# perl Makefile.PL
# make
# make install
测试DBD-ODBC模块是否安装成功:
$perl -e 'use DBD::ODBC;'
$perl -MDBD::ODBC -e 'print $DBD::ODBC::VERSION;'
$perl -MDBI -e 'DBI->installed_versions;'
http://www.easysoft.com/developer/interfaces/odbc/64-bit.html#easysoft
所有的软件到现在都安装完成了,接下来就是配置了
#pwd
/usr/local/freetds/etc
#ls
freetds.conf locales.conf pool.conf
# vi freetds.conf
增加如下内容:
[WIN-SGTEST]
host=192.168.251.218
port=1433
tds version=8.0
--其中的[WIN-SGTEST]代表在客户端使用的服务器名称,host代表SQLServer服务器的IP地址,port代表端口
测试连接;
# /usr/local/freetds/bin/tsql -H 192.168.251.218 -p 1433 -U sa -P 11
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> use sg0157
2> go
1> select count(1) from tb1
2> go
1729
(1 row affected)
1>
[root@sggp bin]# ./tsql -H 192.168.1.127 -p 1433 -U sa -P 11
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
[root@sggp bin]# ./tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.92.79
freetds.conf directory: /usr/local/freetds/etc
MS db-lib source compatibility: yes
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 5.0
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
[root@sggp bin]#