FreeTDS工作正常,但是ODBC无法连接 [英] FreeTDS working, but ODBC cannot connect
问题描述
我正在尝试从具有FreeTDS和unixODBC的Ubuntu 12.04网络服务器上运行到MSSQL服务器的连接.
I am trying to run connect to a MSSQL server from an Ubuntu 12.04 webserver with FreeTDS and unixODBC.
使用tsql我可以通过以下方式连接到服务器
Using tsql i can connect to the server with
~$ tsql -S dbs3 -U <username> -P <password>
没问题.
但是,当我尝试与isql连接时,出现以下错误消息:
When I try to connect with isql however, I get the following error message:
~$ isql -v database3 <username> <password>
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Unknown host machine name.
[ISQL]ERROR: Could not SQLConnect
我的配置文件如下:
odbc.ini
[database3]
Driver=FreeTDS
TDS_Version=8.0
Servername=dbs3
Port=1433
Database=benchmark_res
odbcinst.ini
odbcinst.ini
[FreeTDS]
Description=FreeTDS v0.91
Driver=/usr/local/lib/libtdsodbc.so
Setup=/usr/local/lib/libtdsS.so
Trace=Yes
TraceFile=/tmp/freetds.log
ForceTrave=Yes
UsageCount=1
freetds.conf
freetds.conf
# 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
[dbs3]
host = <server-ip>
port = 1433
tds version = 8.0
I followed the installation guide 1. here and 2. here
isql为什么不能正确连接?
我的猜测是该错误非常明显,但我太愚蠢而看不见它:D
Why isn't isql connecting properly?
My guess is that the mistake is super obvious but I'm just too stupid to see it :D
推荐答案
问题是odbc.ini中的这一行
The issue was this line in odbc.ini
[database3] must be [dbs3] in your case.
对于那些也有此问题的人,也请检查
For those that are also having this problem, Check also the
ServerName = *Points to the name of the server configured in freetds.conf*
这篇关于FreeTDS工作正常,但是ODBC无法连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!