【Linux】freetds安装配置连接MSSQL

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

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

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

如果unixODBC有报错:

[[email protected] 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
[[email protected] freetds-0.91]# cp /usr/local/unixODBC/include/sql.h /usr/local/include/

编译说明:

[[email protected] 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

测试连接:

[[email protected] 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:

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

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

[[email protected] etc]# whereis odbcinst
odbcinst: /usr/bin/odbcinst /etc/odbcinst.ini
时间: 2024-08-30 05:25:23

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

LINUX下使用PHP连接MSSQL的方法

目录[-] 如何安装MSSQL.SO 如何安装PDO_LIB.SO 如何安装PDO_ODBC.SO 作者:Roban lee ([email protected]) LINUX下使用PHP连接MSSQL的方法有很多种,根据不同的环境,可以选择不同的方式,大致方法有以下几种: 使用MSSQL.SO扩展 使用PDO_LIB扩展 使用PDO_ODBC扩展 如何安装MSSQL.SO 1. MSSQL.SO 扩展依赖一个外部包,即 freeTDS, FreeTDS 官网: http://www.freet

minicom在虚拟机(linux)安装配置过程

1. minicom需要ncurses库的支持,否则安装会有问题. A. 下载ncurses.我选择是ncurses-5.6.tar.gz 下载地址:http://directory.fsf.org/project/ncurses/ B. 解压缩到/opt/ncurses目录下.# tar zxvf ncurses-5.5.tar.gz –C /opt/ncurses C. 到ncurses目录下,配置编译ncurses. 源码安装的三个步骤(configure.make.make instal

linux下安装配置tomcat以及tomcat开机自启配置

Linux下Tomcat安装配置以及Windows不能连接服务器Tomcat解决方案 一.从官方网站上下载tomcat软件包. 官网地址: http://tomcat.apache.org/ 点击左侧的 download的一个版本,我选择的是 tomcat7.0,选择一个后缀名为.tar.gz文件直接下载到本地. 二.通过工具SSH Secure 上传至linux服务器中,进行解压 解压tomcat压缩文件: #tar zxvf apache-tomcat-7.0.53.tar.gz 将解压后的

在linux下安装配置Initiator

在linux下安装和配置Initiator 环境 : 开启虚拟机,安装有linux操作系统. 首先打开linux操作系统,进入后使用命令ifconfig –a查看ip地址 在windows下安装安装有SecureCRT 7.1软件或者putty来进行远程控制     在linux下安装Initiator [[email protected] ~]# mkdir -p /mnt/cdron 创建目录并将光盘挂载到/mnt/cdrom目录下 [[email protected] ~]# mount

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

Linux下安装配置MySQL+Apache+PHP+WordPress的详细笔记 Linux下配LMAP环境,花了我好几天的时间.之前没有配置过,网上的安装资料比较混乱,加上我用的版本问题,安装过程中出现了一些错误,经过好几次安装,翻了好多资料,最后找出问题的所在,才把环境搭建好,对于高手来说,这或许不算什么,但对于一个刚入门的新人,却是不一样了,这篇文章记录着我的一些笔记,希望对于那些刚刚入门的人们有所帮助,仅作为参考. 安装首先我们得获得MySQL,Apache,PHP,WordPress

生产环境Linux二进制安装配置MySQL

生产环境Linux二进制安装配置MySQL 一.环境检查rpm -qa |grep libaio #如果没有安装libaio则需要安装.df -hmount /dev/sr0 /mnt二.安装过程1)上传安装程序通过FTP/SFTP上传安装包2)创建创用户,组,创建目录groupadd mysqluseradd -r -g mysql -s /bin/false mysqlmkdir -p /mysql/data/3306/data这里的3306是MySQL默认端口号,/mysql/data目录

Linux下安装配置Apache服务器

Linux下安装配置Apache服务器 1. 安装Apache [[email protected] ~]# yum –y install httpd 2. 启动Apache [[email protected] ~]# systemctl start httpd 3. 查看进程 [[email protected] ~]# systemctl status httpd httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib

阿里云服务器Linux CentOS安装配置(四)yum安装tomcat

阿里云服务器Linux CentOS安装配置(四)yum安装tomcat 1.yum -y install tomcat  执行命令后,会帮你把jdk也安装好 2.tomcat安装目录:/var/lib/tomcat/ 3.tomcat配置目录:/etc/tomcat/ 4.启动tomcat:service tomcat start 5.访问下:curl 127.0.0.1:8080(安装目录里是个空文件夹,所以访问时,没有任何内容返回,这是正常的) 远程访问地址:http://ip:8080(

Linux下安装配置Nexus

一.安装和运行nexus 1.下载nexus:http://www.sonatype.org/nexus/go 可选择tgz和zip格式,以及war,选择tgz或zip时不同版本可能在启动时存在一定问题,可能是因为jdk版本问题,若无法启动请选择2.5或更早的版本 注:nexus 2.6版本之后不再支持jdk1.6 2.安装nexus 若下载war,则将其放置tomcat下的webapp目录中,改名为nexus,运行tomcat服务,即可访问http://localhost:8081/nexus