我使用的是freetds-0.91,下载地址:http://pan.baidu.com/s/1hq68rZY

安装编译(根据需要unixodbc):

[root@zabbixserver / ]# tar zxvf freetds-stable.tgz
[root@zabbixserver / ]# cd freetds-0.91
[root@zabbixserver freetds-0.91]# ./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-shared --enable-static --with-unixodbc=/usr/local/unixODBC
[root@zabbixserver freetds-0.91]# make && make install

如果unixODBC有报错:

[root@zabbixserver freetds-0.91]# ./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib --enable-shared --enable-static --with-unixodbc=/usr/local/unixODBC
...
configure: error: sql.h not found
[root@zabbixserver freetds-0.91]# cp /usr/local/unixODBC/include/sql.h /usr/local/include/ 

编译说明:

[root@zabbixserver freetds-0.91]# ./configure --help
`configure' configures FreeTDS 0.91 to adapt to many kinds of systems. Usage: ./configure [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..'] Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX] By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'. For better control, use the options below. Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/freetds]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR] Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD] Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--disable-largefile omit support for large files
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-static[=PKGS] build static libraries [default=yes]
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--disable-libiconv do not attempt to include libiconv
--disable-rpath do not hardcode runtime library paths
--enable-krb5[=LIB] enable Kerberos support, optionally with library
--enable-sspi enable SSPI support
--disable-odbc do not attempt to build odbc the driver
--disable-apps skip build of src/apps (including tsql)
--disable-server skip build of src/server directory
--disable-pool skip build of src/pool directory
--enable-msdblib for MS style dblib
--enable-sybase-compat enable increased Open Client binary compatibility
--disable-threadsafe disable calls to threadsafe fuctions
e.g.,gethostbyname_r
--disable-debug disable assert and other things
--enable-extra-checks enable extra checks on code
--enable-developing enable code still in develop
--enable-odbc-wide enable wide string support in odbc [experimental]
--enable-distcheck-build
used internally for testing Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-pic try to use only PIC/non-PIC objects [default=use
both]
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-gnu-ld assume the C compiler uses GNU ld default=no
--with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib
--without-libiconv-prefix don't search for libiconv in includedir and libdir
--with-tdsver=VERSION TDS protocol version (4.2/4.6/5.0/7.0/7.1) [5.0]
--with-iodbc=DIR build odbc driver against iODBC in DIR
--with-unixodbc=DIR build odbc driver against unixODBC in DIR
--with-odbc-nodm=DIR build odbc using headers in DIR/include
--with-gnutls build with TLS support
--with-openssl --with-openssl=DIR build with OpenSSL (license NOT
compatible cf. User Guide) Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider.

编译完修改freetds配置:

[ser2008]
host = 100.10.10.100
port = 1433
tds version = 8.0
client chaeset = UTF-8

测试连接:

[root@zabbixserver freetds-0.91]#  /usr/local/freetds/bin/tsql -S ser2008 -U user -P passwd
locale is "zh_CN.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> use test_database
2> go
1> select * from test_table
2> go

unixODBC下载地址:http://www.unixodbc.org/

参考:http://www.cnblogs.com/trams/archive/2011/12/02/2272079.html

安装unixODBC:

[root@zabbixserver unixODBC-2.3.2 ]# ./configure --prefix=/usr/local/unixODBC --includedir=/usr/include --libdir=/usr/lib -bindir=/usr/bin --sysconfdir=/etc
[root@zabbixserver unixODBC-2.3.2 ]# make && make install

yum安装的,大致方法一样,但不建议,yum安装的配置文件位置:

[root@zabbixserver etc]# whereis odbcinst
odbcinst: /usr/bin/odbcinst /etc/odbcinst.ini

配置unixODBC:

参考http://blog.csdn.net/gzlaiyonghao/article/details/3838967

注意odbcinst.ini中的Driver名字要和odbc.ini中的一致,odbc.ini中的Server要和freetds中的Server名字一致

[root@zabbixserver etc]# vim odbcinst.ini
[ODBC]
Trace = Yes
TraceFile = /tmp/sql.log
ForceTrace = Yes
Pooling = No
[SQLSERVER]
Description = SQLSERVER
Driver = /usr/local/freetds/lib/libtdsodbc.so
Driver64 = /usr/local/freetds/lib/libtdsodbc.so
Setup = /usr/local/freetds/lib/libtds.so
Setup64 = /usr/local/freetds/lib/libtds.so
UsageCount = 1
CPTimeout = 5
CPReuse = 5
FileUsage = 1 [root@zabbixserver etc]# vim odbc.ini
[jd_msg]
Driver = SQLSERVER
Description = SQLSERVER
Server = ser2008
Database = test_database
Port = 1433

报错1:

[root@zabbixserver etc]# isql test_database user password
isql: error while loading shared libraries: libodbc.so.2: cannot open shared object file: No such file or directory

参考http://blog.csdn.net/m_star_jy_sy/article/details/8530706

[root@zabbixserver etc]# echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib"  >> /etc/bashrc
[root@zabbixserver etc]# source /etc/bashrc

报错2:

[root@zabbixserver etc]# isql test_database user password
[ISQL]ERROR: Could not SQLConnect

【Linux】freetds安装配置连接MSSQL的更多相关文章

  1. 阿里云服务器Linux CentOS安装配置(三)yum安装mysql

    阿里云服务器Linux CentOS安装配置(三)yum安装mysql 1.执行yum安装mysql命令:yum -y install mysql-server mysql-devel 2.启动mys ...

  2. 阿里云服务器Linux CentOS安装配置(二)yum安装svn

    阿里云服务器Linux CentOS安装配置(二)yum安装svn 1.secureCRT连接服务器 2.先创建一个文件夹,用来按自己的习惯来,用来存放数据 mkdir /data 3.yum安装sv ...

  3. (转载)Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记

    Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记 Linux下配LMAP环境,花了我好几天的时间.之前没有配置过,网上的安装资料比较混乱,加上我用的版本问题,安装过程 ...

  4. linux上安装配置samba服务器

    linux上安装配置samba服务器 在linux上安装配置samba服务器 在这给大家介绍一个不错的家伙,samba服务.如果您正在犯愁,如何在Windows和Linux之间实现资源共享,就请看看这 ...

  5. Linux下安装配置MySQL5.7服务器

    Linux下安装配置MySQL服务器 一.安装环境 ============ OS:centos6.8 MySQL:mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz ...

  6. 详解在Linux中安装配置MongoDB

    最近在整理自己私人服务器上的各种阿猫阿狗,正好就顺手详细记录一下清理之后重装的步骤,今天先写点数据库的内容,关于在Linux中安装配置MongoDB 说实话为什么会装MongoDB呢,因为之前因为公司 ...

  7. 详解在Linux中安装配置MySQL

    最近在整理自己私人服务器上的各种阿猫阿狗,正好就顺手详细记录一下清理之后重装的步骤,今天先写点数据库的内容,关于在Linux中安装配置MySQL 安装环境 CentOS7 + MySQL5.7 下载安 ...

  8. 阿里云服务器Linux CentOS安装配置(零)目录

    阿里云服务器Linux CentOS安装配置(零)目录 阿里云服务器Linux CentOS安装配置(一)购买阿里云服务器 阿里云服务器Linux CentOS安装配置(二)yum安装svn 阿里云服 ...

  9. 阿里云服务器Linux CentOS安装配置(九)shell编译、打包、部署

    阿里云服务器Linux CentOS安装配置(九)shell编译.打包.部署 1.查询当前目录以及子目录下所有的java文件,并显示查询结果 find . -name *.java -type f - ...

随机推荐

  1. Kmeans算法学习与SparkMlLib Kmeans算法尝试

    K-means算法是最为经典的基于划分的聚类方法,是十大经典数据挖掘算法之一.K-means算法的基本思想是:以空间中k个点为中心进行聚类,对最靠近他们的对象归类.通过迭代的方法,逐次更新各聚类中心的 ...

  2. 使用Visual Studio 2013 调试 MASM 汇编程序!

    原文地址:http://kipirvine.com/asm/debug/vstudio2013/index.htm Using the Microsoft Visual Studio 2013 Deb ...

  3. Run Configuration error:broken configuration due to unavailable

    希望大家一起来,毕竟大家都不会使用这个Androidstudio,一起扩展这方面的知识量 http://forums.opengamma.com/t/intellij-code-compiles-bu ...

  4. C++学习10 static静态成员变量和静态成员函数

    一般情况下,如果有N个同类的对象,那么每一个对象都分别有自己的成员变量,不同对象的成员变量各自有值,互不相干.但是有时我们希望有某一个或几个成员变量为所有对象共有,这样可以实现数据共享. 可以使用全局 ...

  5. Python之几个技巧特点

    今天偶然看到一篇文章<你可能不知道的30个Python语言的提点技巧>,虽然做python有几年了,但中间还是好多不知道或没想到,特在这里做下摘抄. 原文地址: http://soft.c ...

  6. Android 上的代码阅读器 CoderBrowserHD 修改支持 go 语言代码

    我在Android上的代码阅读器用的是 https://github.com/zerob13/CoderBrowserHD 改造的版本,改造后的版本我放在 https://github.com/ghj ...

  7. C Primer Plus(第五版)7

    第 7 章 C 控制语句:分支和跳转 在本章中你将学习下列内容: · 关键字:if(如果),else(否则),switch(切换),continue(继续),break(中断), case(情况),d ...

  8. nyoj 70 阶乘因式分解(二)

    点击打开链接 阶乘因式分解(二) 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 给定两个数n,m,其中m是一个素数. 将n(0<=n<=2^31)的阶乘分解 ...

  9. POJ 3308 Paratroopers(最小割EK(邻接表&矩阵))

    Description It is year 2500 A.D. and there is a terrible war between the forces of the Earth and the ...

  10. ORA-00245: control file backup failed; target is likely on a local file system (转载)

    环境:DB VERSION: 11.2.0.4.0RAC 2 nodes 问题:邮件显示rman备份失败,查看rman备份日志 Starting Control File and SPFILE Aut ...