将 Redhat 连接到 SQL Server 2008 以实现 Ruby on Rails
我正在尝试将 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您无法连接 tsql,则表明您的 SQL 服务器或
freetds.conf
存在连接问题。首先使用 tsql -LH [SQL 服务器 IP] 验证端口和命名实例。
如果这不起作用,则您的服务器和 SQL 服务器之间存在连接问题。
如果它确实有效,请在
freetds.conf
中将您的端口设置为与上面的 tcp 匹配。实例在您的 odbc.ini 中设置
,如果其他方法都失败,请尝试使用 osql 来获取有关哪个部分不起作用的反馈。
有关 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]
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
.Instance is set in your
odbc.ini
And if all else fails, try using
osql
to get some feedback on which part is not working.And for some good info on tsql error messages: http://freetds.schemamania.org/userguide/confirminstall.htm
freetds.conf 文件中不需要 SQL Server 主机名或 IP 地址吗?
Won't you need the SQL Server hostname or IP address in the freetds.conf file --