【问题标题】:ubuntu tsql working and isql not workingubuntu tsql 工作和 isql 不工作
【发布时间】:2017-01-13 04:48:24
【问题描述】:

我正在尝试使用 FreeTDS 和 unixODBC 将 MSSQL 服务器连接到 ubuntu 14.04。

我可以使用 tsql 连接:

~$ tsql -S MSSQL -U <username> -P <password>

这可以正常工作。

当尝试使用 isql 时,我得到以下信息

isql -v MSSQL <username> <password>
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[ISQL]ERROR: Could not SQLConnect

这是我的配置。

odbc.ini

[MSSQL]
Driver = FreeTDS
TDS_Version = 8.0
Server = <server>
Instance = dev
Database = <database>

odbcinst.ini

[FreeTDS]
Description = FreeTDS
Driver = /usr/local/lib/libtdsodbc.so
Setup = /usr/local/lib/libtdsodbc.so
Trace = Yes
TraceFile = /tmp/freetds.log
ForceTrace = Yes

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 = 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

[MSSQL]
        host = <host>
        instance = dev
        tds version = 8.0

我认为问题是由驱动程序引起的,我认为我不应该收到错误消息说驱动程序不可执行。这是 osql 输出:

osql -S MSSQL -U <username> -P <password>
checking shared odbc libraries linked to isql for default directories...
strings: '': No such file
        trying /tmp/sql ... no
        trying /tmp/sql ... no
        trying /etc ... OK
checking odbc.ini files
        reading /home/<user>/.odbc.ini
[MSSQL] found in /home/<user>/.odbc.ini
found this section:
        [MSSQL]
        Driver = FreeTDS
        TDS_Version = 8.0
        Server = <server>
        Database = <database>
looking for driver for DSN [MSSQL] in /home/<user>/.odbc.ini
  found driver line: "  Driver = FreeTDS"
  driver "FreeTDS" found for [MSSQL] in .odbc.ini
found driver named "FreeTDS"
"FreeTDS" is not an executable file
looking for entry named [FreeTDS] in /etc/odbcinst.ini
  found driver line: "  Driver = /usr/local/lib/libtdsodbc.so"
  found driver /usr/local/lib/libtdsodbc.so for [FreeTDS] in odbcinst.ini
/usr/local/lib/libtdsodbc.so is an executable file
"Server" found, not using freetds.conf
Server is <server_name>

Configuration looks OK.  Connection details:

                   DSN: MSSQL
              odbc.ini: /home/<user>/.odbc.ini
                Driver: /usr/local/lib/libtdsodbc.so
       Server hostname: <host>
               Address: <ip_address>

Attempting connection as <username> ...
+ isql MSSQL <username> <password> -v
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[ISQL]ERROR: Could not SQLConnect

感谢您的帮助。

【问题讨论】:

    标签: sql-server ubuntu freetds unixodbc


    【解决方案1】:

    我找到了我的问题的答案。我需要像这样在 odbc.ini 文件中将实例添加到服务器

    MSSQL]
    Driver = FreeTDS
    TDS_Version = 8.0
    Server = <server\dev>
    Database = <database>
    

    这让我执行 isql。

    【讨论】:

    • 您也应该从不使用 TDS 8.0 版。它早已被弃用,因为它是对 TDS 版本的猜测,但从未真正实现。 TDS 8.0 版实际上回退到 7.1 版,所以使用 7.1 并且如果您最终使用更新版本的 FreeTDS,您将不会遇到未来的错误。详情见这里:freetds.org/userguide/choosingtdsprotocol.htm
    猜你喜欢
    • 2012-11-09
    • 2012-04-30
    • 2015-12-28
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    • 2015-05-20
    • 2016-03-17
    • 2017-01-13
    相关资源
    最近更新 更多