将Redhat连接到SQL Server 2008以获取Ruby on Rails

oma*_*oum 5 redhat unixodbc freetds sql-server-2008 ruby-on-rails-3

我正在尝试将Redhat Linux连接到Microsoft SQL Server 2008.我已经在Windows(我的测试机器)上设置它时遇到了麻烦,但现在我需要将它部署在将要投入生产的Linux机器上.

所以我已经安装了unixODBC和FreeTDS(需要付出很多努力,甚至不确定它是否安装正确:S),结果是我有3个文件/usr/local/etc:

odbc.ini
odbcinst.ini
freetds.conf
Run Code Online (Sandbox Code Playgroud)

然后我编辑了freetds.conf文件,这是我添加的内容:

[sqlServer]
host = servername
port = 4113
instance = sqlServer
tds version = 8.0
client charset = UTF-8
Run Code Online (Sandbox Code Playgroud)

我必须从我的DBA中找到端口号,因为它在SQL Server 2008中设置为动态.

我的odbcinst.ini文件看起来像这样:

[FreeTDS]
Description     = TDS driver (Sybase/MS SQL)
Driver          = /usr/local/lib/libtdsodbc.so
Setup           = /usr/local/lib/libtdsS.so
CPTimeout       =
CPReuse         =
FileUsage       = 1
Run Code Online (Sandbox Code Playgroud)

我的odbc.ini文件看起来像这样:

[sqlServer]
Driver = FreeTDS
Description     = ODBC connection via FreeTDS
Trace           = 1
Servername      = sqlServer
Database        = RubyApp
Run Code Online (Sandbox Code Playgroud)

所以现在我尝试连接以查看是否有任何连接使用

tsql -S sqlServer -U test -P test,但这只会给我以下错误:

locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20013 (severity 2):
        Unknown host machine name.
There was a problem connecting to the server
Run Code Online (Sandbox Code Playgroud)

当我尝试使用isql时,执行isql -v sqlServer test test,吐出以下错误:

[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
Run Code Online (Sandbox Code Playgroud)

我有什么想法可能做错了吗?

小智 0

您不需要 freetds.conf 文件中的 SQL Server 主机名或 IP 地址吗?

[sqlServer]
host = 192.168.0.99
:
Run Code Online (Sandbox Code Playgroud)