【问题标题】:FreeTDS can't read Servername from odbc.iniFreeTDS 无法从 odbc.ini 读取服务器名称
【发布时间】:2016-03-10 13:05:21
【问题描述】:

我正在尝试设置 FreeTDS 以连接到 Ubuntu 14.04 和 FreeTDS 4.2 中的 mssql 服务器

但是由于未知原因,osql 无法读取 Servername 设置。 如果我使用 isql,它可以工作。但是我的程序使用 odbc.ini 设置。

我做错了什么?

我的 odbc.ini;

[ODBC Data Sources]
Test = My Test Server

[mssql]
Description = My Test Server
Driver      = FreeTDS
Trace       = No
TDS_Version = 4.2
Servername  = mssql

命令

~$ osql -S mssql -U user -P password 
checking shared odbc libraries linked to isql for default directories...
strings: '': No hay tal fichero
    trying /tmp/sql ... no
    trying /tmp/sql ... no
    trying /etc ... OK
checking odbc.ini files
    reading /home/business/.odbc.ini
[mssql] not found in /home/business/.odbc.ini
    reading /etc/odbc.ini
[mssql] found in /etc/odbc.ini
found this section:
    [mssql]
    Description = My Test Server
    Driver      = FreeTDS
    Trace       = No
    TDS_Version = 4.2
    Servername  = mssql

looking for driver for DSN [mssql] in /etc/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/lib/x86_64-linux-gnu/odbc/libtdsodbc.so"
  found driver /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so for [FreeTDS] in odbcinst.ini
/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so is an executable file
Using ODBC-Combined strategy
DSN [mssql] has servername "" (from /etc/odbc.ini)

【问题讨论】:

    标签: sql-server ubuntu odbc freetds


    【解决方案1】:

    您需要在此处解决一些问题。首先,在odbc.ini 中,是“服务器”而不是“服务器名称”。这是一个例子。

    odbc.ini:

    [myserver]
    Driver = FreeTDS
    Server = myserver.mydomain.com
    Port = 1433
    TDS_Version = 7.2
    

    freetds.conf:

    [myserver]
    host = myserver.mydomain.com
    port = 1433
    tds version = 7.2
    

    此外,您还需要使用更高的 TDS 版本。 TDS 4.2 适用于 Microsoft SQL Server 6.0!尽管有文档,但我发现它并非适用于所有产品。要选择合适的 TDS 版本,请参见此处:

    http://www.freetds.org/userguide/choosingtdsprotocol.htm

    您很可能需要 7.2 或 7.3 版本。祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-05
      相关资源
      最近更新 更多