将 Redhat 连接到 SQL Server 2008 以实现 Ruby on Rails

发布于 2024-12-06 16:51:46 字数 1601 浏览 1 评论 0原文

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

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

odbc.ini
odbcinst.ini
freetds.conf

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

[sqlServer]
host = servername
port = 4113
instance = sqlServer
tds version = 8.0
client charset = UTF-8

我必须从 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

我的 odbc.ini 文件如下所示:

[sqlServer]
Driver = FreeTDS
Description     = ODBC connection via FreeTDS
Trace           = 1
Servername      = sqlServer
Database        = RubyApp

所以现在我尝试使用

tsql 连接以查看是否有任何连接-S sqlServer -U 测试 -P 测试, 但是,这只给了我以下错误:

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

当我尝试使用 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

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

I'm trying to connect Redhat Linux to a Microsoft SQL Server 2008. I already had trouble setting it up on windows (my test machine) but now I need to deploy it on the Linux machine where it will be in production.

So I've installed unixODBC and FreeTDS (with a lot of effort, not even sure if it was installed correctly :S), and the outcome of that is that I have 3 files in /usr/local/etc:

odbc.ini
odbcinst.ini
freetds.conf

I then edited the freetds.conf file and this is what I added:

[sqlServer]
host = servername
port = 4113
instance = sqlServer
tds version = 8.0
client charset = UTF-8

I had to find out the port number from my DBA, as it is set to dynamic in SQL Server 2008.

My odbcinst.ini file looks like this:

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

and my odbc.ini files looks like this:

[sqlServer]
Driver = FreeTDS
Description     = ODBC connection via FreeTDS
Trace           = 1
Servername      = sqlServer
Database        = RubyApp

So now I tried connecting to see if there is any connection by using

tsql -S sqlServer -U test -P test,
however that only gives me the following error:

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

When I tried using isql, doing isql -v sqlServer test test, that spat out the following error:

[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

Any ideas what I could be doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

标点 2024-12-13 16:51:46

如果您无法连接 tsql,则表明您的 SQL 服务器或 freetds.conf 存在连接问题。

首先使用 tsql -LH [SQL 服务器 IP] 验证端口和命名实例。

# tsql -LH 127.0.0.1
  ServerName HOME
InstanceName INSTANCE1
 IsClustered No
     Version 10.50.2500.0
         tcp 1434

如果这不起作用,则您的服务器和 SQL 服务器之间存在连接问题。

如果它确实有效,请在 freetds.conf 中将您的端口设置为与上面的 tcp 匹配。

[TDS]
host = 127.0.0.1
port = 1434
tds version = 7.0

实例在您的 odbc.ini 中设置

[MSSQLExample]
Description = Example server
Driver = FreeTDS
Trace = No
Server = 127.0.0.1\INSTANCE1
Database = MyDatabase
port = 1434

,如果其他方法都失败,请尝试使用 osql 来获取有关哪个部分不起作用的反馈。

# osql -S MSSQLExample -U USERNAME -P PASSWORD

有关 tsql 错误消息的一些好信息: http://freetds.schemamania.org/userguide/confirminstall .htm

If you cannot connect with tsql, then there is a connection issue with your SQL server or in freetds.conf.

First verify the port and named instance using tsql -LH [SQL server IP]

# tsql -LH 127.0.0.1
  ServerName HOME
InstanceName INSTANCE1
 IsClustered No
     Version 10.50.2500.0
         tcp 1434

If this doesn't work, there is a connection issue between your server and the SQL server.

If it does work, then set your port to match tcp above in freetds.conf.

[TDS]
host = 127.0.0.1
port = 1434
tds version = 7.0

Instance is set in your odbc.ini

[MSSQLExample]
Description = Example server
Driver = FreeTDS
Trace = No
Server = 127.0.0.1\INSTANCE1
Database = MyDatabase
port = 1434

And if all else fails, try using osql to get some feedback on which part is not working.

# osql -S MSSQLExample -U USERNAME -P PASSWORD

And for some good info on tsql error messages: http://freetds.schemamania.org/userguide/confirminstall.htm

对不⑦ 2024-12-13 16:51:46

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

[sqlServer]
host = 192.168.0.99
:

Won't you need the SQL Server hostname or IP address in the freetds.conf file --

[sqlServer]
host = 192.168.0.99
:
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文