CentOS下安装FreeTDS

2019-11-05 09:51:25来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

CentOS下安装FreeTDS

导读

官方网站:http://www.freetds.org

下载地址:http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz

这个软件能够用Linux和Unix连接MS SQLServer和Sybase数据库

安装与配置
  1. 首先下载FreeTDS安装包到服务器

    wget -c http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz

    1

  2. 解压

    tar -zxvf freetds-stable.tgz

    2

  3. 编译安装

    1. 因为是编译安装所以确保机器有安装gcc(可使用yum进行安装)

      yum install gcc-c++
      yum install ncurses-devel
    2. 开始安装

      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

    3

    4

    5

  4. FreeTDS默认安装在/usr/local/freetds目录当中,库文件在相应的lib目录下。

    vim /etc/ld.so.conf加入一行 /usr/local/freetds/lib

  5. 然后运行以下指令使更改生效:

    ldconfig
  6. 测试连接

    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版本的问题

    两种解决方式:

    1. 修改全局TDS 版本号

      找到/usr/local/etc/freetds.conf修改[global]下面的tds version8.0

    2. 连接时修改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

    这个毋庸置疑了,找管理员开通白名单再访问吧!


原文链接:https://www.cnblogs.com/alterem/p/11798202.html
如有疑问请与原作者联系

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:Java的参数传递是「按值传递」还是「按引用传递」?

下一篇:Java——比较两个日期相差的天数