FreeTDS 无法从 odbc.ini 读取服务器名
FreeTDS can't read Servername from odbc.ini
我正在尝试设置 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)
您需要在此处解决一些问题。首先,在 odbc.ini
中,是 "Server" 而不是 "Servername"。这是一个例子。
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!尽管有文档,但我发现它不适用于所有产品。要 select 合适的 TDS 版本,请参阅此处:
http://www.freetds.org/userguide/choosingtdsprotocol.htm
您很可能需要 7.2 或 7.3 版。祝你好运!
我正在尝试设置 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)
您需要在此处解决一些问题。首先,在 odbc.ini
中,是 "Server" 而不是 "Servername"。这是一个例子。
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!尽管有文档,但我发现它不适用于所有产品。要 select 合适的 TDS 版本,请参阅此处:
http://www.freetds.org/userguide/choosingtdsprotocol.htm
您很可能需要 7.2 或 7.3 版。祝你好运!