Sql-Server
“未知的主機名。”在 FreeBSD + unixODBC + FreeTDS 上
我從我的 FreeBSD 10.1 伺服器連接到 Microsoft SQL Server 2012 時遇到了一些問題。
我通過埠安裝了 FreeTDS 和 unixODBC。我用 unixODBC 支持編譯了 FreeTDS。這是我的 freetds.conf:
[server1] host = 192.168.100.147 port = 1433 tds version = 7.2
呼叫 tsql 工作正常。
但是當我嘗試通過 odbc 與“osql”或“isql”連接時,連接失敗並出現以下錯誤:
checking shared odbc libraries linked to isql for default directories... trying /tOH ... no trying /tOH ... no trying /tmp/sqlH ... no trying /tmp/sqlH ... no trying /usr/locH ... no trying /usr/locH ... no trying /tmp/sql.log ... no trying /home ... no trying /.odbc.ini ... no trying /usr/local/etc ... OK checking odbc.ini files reading /root/.odbc.ini [server1] not found in /root/.odbc.ini reading /usr/local/etc/odbc.ini [server1] found in /usr/local/etc/odbc.ini found this section: [server1] Driver = FreeTDS Servername = server1 looking for driver for DSN [server1] in /usr/local/etc/odbc.ini found driver line: " Driver = FreeTDS" driver "FreeTDS" found for [server1] in odbc.ini found driver named "FreeTDS" "FreeTDS" is not an executable file looking for entry named [FreeTDS] in /usr/local/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 Using ODBC-Combined strategy DSN [server1] has servername "server1" (from /usr/local/etc/odbc.ini) cannot read "/root/.freetds.conf" /usr/local/etc/freetds/freetds.conf is a readable file looking for [server1] in /usr/local/etc/freetds/freetds.conf found this section: [server1] host = 192.168.100.147 port = 1433 tds version = 7.2 looking up hostname for ip address 192.168.100.147 Configuration looks OK. Connection details: DSN: server1 odbc.ini: /usr/local/etc/odbc.ini Driver: /usr/local/lib/libtdsodbc.so Server hostname: sqlsrv01 Address: 192.168.100.147 Attempting connection as sa ... + isql server1 sa foobar -v [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 的內容:
[server1] Driver = FreeTDS Servername = server1
這是我的 odbcinst.ini:
[FreeTDS] Driver = /usr/local/lib/libtdsodbc.so Client Charset = UTF-8 UsageCount = 1
我閱讀了有關使用確切命名資訊 odbc.ini 和 freetds.conf 的嚴重文章,但連接一直失敗。
有人可以幫忙嗎?
我現在可以回答我自己的問題了。
根據我呼叫的 unixODBC 郵件列表1的提示
odbcinst -i -s -f /usr/local/etc/odbc.ini
現在我可以通過 osql 連接到伺服器了。