2016-09-05 38 views
2

我想连接MSSQL服务器到FreeTDS和unixODBC的Ubuntu 14.04。ubuntu tsql工作和isql不工作

我可以连接使用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 

这里是我的configs。

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 

任何帮助表示赞赏,谢谢。

回答

2

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

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

这让我执行ISQL。

+1

你也应该*从不*使用TDS版本8.0。它已被长期弃用,因为它是从未实际实现的TDS版本的猜测。 TDS版本8.0实际上可以回退到7.1版本,所以使用7.1版本,如果您最终使用FreeTDS的更新版本,则不会遇到未来的错误。详情请参阅:http://www.freetds.org/userguide/choosingtdsprotocol.htm – FlipperPA