2016-09-05 7 views
2

Я пытаюсь подключить MSSQL-сервер к ubuntu 14.04 с помощью FreeTDS и unixODBC.ubuntu tsql working и 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 

Вот мои конфиги.

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 Version 8.0. Он давно устарел, поскольку это было предположение о версии TDS, которая никогда не материализовалась. Версия TDS Version 8.0 фактически возвращается к версии 7.1, поэтому используйте 7.1, и вы не столкнетесь с будущей ошибкой, если закончите новую версию FreeTDS. Подробнее см. Здесь: http://www.freetds.org/userguide/choosingtdsprotocol.htm – FlipperPA