centos - unixODBC 和 FreeTDS 配置问题

标签 centos freetds unixodbc

我已经为此工作了太久,似乎无法弄清楚。我确定我的 freetds.conf、odbc.ini 或 odbcinst.ini 有问题。我可以使用 tsql 连接到我的 mssql 2008 服务器,但仍然不能使用 isql 或者当然不能通过 php。

我在 CentOS 5.6 上。

谁能提供一些帮助?

谢谢! 肖恩

这是在我的 sqltrace.log 中:

 [ODBC][12249][1347850711.939084][__handles.c][459]
    Exit:[SQL_SUCCESS]
    Environment = 0x1b5fc6c0
    [ODBC][12249][1347850711.939149][SQLAllocHandle.c][375]
    Entry:
        Handle Type = 2
            Input Handle = 0x1b5fc6c0
[ODBC][12249][1347850711.939187][SQLAllocHandle.c][493]
        Exit:[SQL_SUCCESS]
            Output Handle = 0x1b5fcff0
[ODBC][12249][1347850711.939231][SQLConnect.c][3654]
        Entry:
            Connection = 0x1b5fcff0
            Server Name = [MSSQL_DSN][length = 9 (SQL_NTS)]
            User Name = [InetIndyArtsRemote][length = 18 (SQL_NTS)]
            Authentication = [**********][length = 10 (SQL_NTS)]
        UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'

        DIAG [01000] [FreeTDS][SQL Server]Unexpected EOF from the server

        DIAG [01000] [FreeTDS][SQL Server]Adaptive Server connection failed

        DIAG [S1000] [FreeTDS][SQL Server]Unable to connect to data source

[ODBC][12249][1347850711.949640][SQLConnect.c][4021]
        Exit:[SQL_ERROR]
[ODBC][12249][1347850711.949694][SQLFreeHandle.c][286]
        Entry:
            Handle Type = 2
            Input Handle = 0x1b5fcff0
[ODBC][12249][1347850711.949735][SQLFreeHandle.c][337]
        Exit:[SQL_SUCCESS]
[ODBC][12249][1347850711.949773][SQLFreeHandle.c][219]
        Entry:
            Handle Type = 1
            Input Handle = 0x1b5fc6c0

freetds.conf:

    #   $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
    #
    # This file is installed by FreeTDS if no file by the same
    # name is found in the installation directory.
    #
    # For information about the layout of this file and its settings,
    # see the freetds.conf manpage "man freetds.conf".

    # Global settings are overridden by those in a database
    # server specific section
    [global]
            # TDS protocol version
            tds version = 8.0

            # Whether to write a TDSDUMP file for diagnostic purposes
            # (setting this to /tmp is insecure on a multi-user system)
            dump file = /tmp/freetds.log
            debug flags = 0xffff
            dump file append = yes

            # Command and connection timeouts
    ;       timeout = 10
    ;       connect timeout = 10

            # If you get out-of-memory errors, it may mean that your client
            # is trying to allocate a huge buffer for a TEXT field.
            # Try setting 'text size' to a more reasonable limit
            text size = 64512

[IndyArtsDB]
        host = xxx.xx.xxx.xx
        port = 1433
        tds version = 8.0
        client charset = UTF-8

ODBC.INI

[MSSQL_DSN]
Driver=FreeTDS
Description=IndyArts DB on Rackspace
Trace=No
Server=xxx.xx.xxx.xx
Port=1433
Database=DBName

ODCBINST.INI

[ODBC]
DEBUG=1
TraceFile=/home/ftp/sqltrace.log
Trace=Yes

[FreeTDS]
Description=MSSQL Driver
Driver=/usr/local/lib/libtdsodbc.so
UsageCount=1

最佳答案

查看您的 sqltrace.log,它在我看来像是身份验证错误 - 您在身份验证后立即收到“来自服务器的意外 EOF”消息...

远程服务器是否有可能完全或在端口 1433 上阻止来自您的 CentOS 服务器的连接?有没有可能是您的 freetds.conf 中的“client charset = UTF-8”导致了问题?

这是我在 Ubuntu 12.04(Precise Pangolin)机器上的(工作)设置。

这是我的/etc/odbc.ini 文件:

[xyz]
Description             = XYZ Server
Driver                  = freetds
Database                = MyDB
ServerName              = xyz
TDS_Version             = 8.0

还有我的/etc/odbcinst.ini 文件:

[freetds]
Description     = MS SQL database access with Free TDS
Driver          = /usr/lib/i386-linux-gnu/odbc/libtdsodbc.so
Setup           = /usr/lib/i386-linux-gnu/odbc/libtdsS.so
UsageCount      = 1

最后是我的/etc/freetds/freetds.conf 文件:

[global]
        # TDS protocol version
;       tds version = 4.2

        # Whether to write a TDSDUMP file for diagnostic purposes
        # (setting this to /tmp is insecure on a multi-user system)
;       dump file = /tmp/freetds.log
;       debug flags = 0xffff

        # Command and connection timeouts
;       timeout = 10
;       connect timeout = 10

        # If you get out-of-memory errors, it may mean that your client
        # is trying to allocate a huge buffer for a TEXT field.  
        # Try setting 'text size' to a more reasonable limit 
        text size = 64512

# A typical Sybase server
[egServer50]
        host = symachine.domain.com
        port = 5000
        tds version = 5.0

# A typical Microsoft server
[egServer70]
        host = ntmachine.domain.com
        port = 1433
        tds version = 7.0

# The XYZ database
[xyz]
        host = XYZ
        port = 1433
        tds version = 8.0

关于centos - unixODBC 和 FreeTDS 配置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12452747/

相关文章:

php - 在 PHP PDO-ODBC、unixODBC 和 FreeTDS 中使用类型化绑定(bind)参数

Python2.7 - 在 CentOS 6.3 上 pip install pymssql 失败

php - UnixODBC 多个数据源不起作用

python - pypyodbc 在 isql 连接时不连接?

php - 如何使用 PHP 在 RedHat Linux 上为 SQL Server® 配置 Microsoft® ODBC Driver 11

linux - 安装 2 个版本时如何选择要使用的默认 Subversion (svn) 版本

java - 从 java 运行 Bash 不起作用

linux - centos 7 AWS(使用 ssh key 和密码登录)

Centos - 如何安装特定版本的 Erlang?

php - 在 Linux 上从 PHP 连接到 MS SQL Server