Install FreeTDS under CentOS

Keywords: Java Linux Database yum SQL

Guide reading

Official website: http://www.freetds.org

Download address: http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz

This software can connect MS SQL server and Sybase database with Linux and Unix

Installation and configuration
  1. Download the FreeTDS installation package to the server first

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

  2. decompression

    tar -zxvf freetds-stable.tgz

  3. Compilation and installation

    1. Make sure that gcc is installed on the machine because it is a compiled installation (it can be installed using yum)

      yum install gcc-c++
      yum install ncurses-devel
    2. Start installation

      cd freetds-0.91/
      ./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib
      make && makeinstall

      Explanation: install freetds to directory / usr/local/freetds: -- prefix=/usr/local/freetds support MSSQL2000: - with tdsver = 8.0 -- enable msdblib

  4. FreeTDS is installed in the / usr/local/freetds directory by default, and the library files are in the corresponding lib directory.

    vim /etc/ld.so.conf add a line / usr/local/freetds/lib

  5. Then run the following command for the changes to take effect:

    ldconfig
  6. Test connection

    tsql -H MSSQL server service IP -p 1433 -U MSSQL server login account - P MSSQL server login password

    $  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)
    problem

    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

    Execute 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

    It is found that the version of freetds is 5.0. Considering that it may be the version of freetds

    Two solutions:

    1. Modify global TDS version number

      Find / usr/local/etc/freetds.conf and change the tds version under [global] to 8.0

    2. Modify tds version number when connecting

      TDSVER=7.0 tsql -H

      The entire connection command changes to:

      tsql -H MSSQL server service IP -p 1433 -U MSSQL server login account - P MSSQL server login password

    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

    There is no doubt about this. Go to the administrator to open the white list and visit again!

Posted by ccjob2 on Tue, 05 Nov 2019 13:34:30 -0800