I got some issues connecting to a Microsoft SQL Server 2012 from my FreeBSD 10.1 server.

I installed FreeTDS and unixODBC via ports. I compiled FreeTDS with unixODBC support. This ist my freetds.conf:

  host =
  port = 1433
  tds version = 7.2

Invoking tsql works fine.

But when i try to connect via odbc with "osql" or "isql" the connection failes with the following error:

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:
      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:
        host =
        port = 1433
        tds version = 7.2
looking up hostname for ip address

Configuration looks OK.  Connection details:

                   DSN:    server1
              odbc.ini:    /usr/local/etc/odbc.ini
                Driver:    /usr/local/lib/libtdsodbc.so
       Server hostname:    sqlsrv01

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

This is the content of my odbc.ini:

  Driver = FreeTDS
  Servername = server1

And this is my odbcinst.ini:

  Driver = /usr/local/lib/libtdsodbc.so
  Client Charset = UTF-8
  UsageCount = 1

I read severeal posts regarding to using the exact naming inf odbc.ini and freetds.conf, but the connection keeps failing.

Can anybody help?


I'm now able to answer my own question.

Following a hint from the unixODBC mailinglist 1 I invoked

odbcinst -i -s -f /usr/local/etc/odbc.ini

and now I am able to connect to the server via osql.

  • +1 for answering your own question although not very active member of the site. You've got the concept. Thanks! – Daniel Böhmer Jan 18 '16 at 16:13
  • Worx great for isql -v ODBCname user pass connection issues – Jadeye Aug 28 '16 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.