Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Install TDS on Centos

Posted on 2013-06-20
Medium Priority
Last Modified: 2013-06-24
I have setup a testing Centos and try to setup the TDS and ODBC on my Centos in order to connect to MS SQL Server.

1. yum install unixODBC.x86_64

2. wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-stable.tgz 
        ./configure --prefix=/usr/local  
        make install

Configure the /usr/local/etc/freetds.conf and connect to MS SQL, it works fine.

Checking my production server, there is also ODBC setting.(odbc.ini) that refer a driver : /usr/local/lib/libtdsodbc.so.  However, I can't find this library in my testing Centos. Should it be installed with steps mentioned below.

What's the usage for this odbc.ini ? Seem like setting up the freetds.conf can connect to MS SQL ? Any idea ?

Question by:AXISHK
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7

Author Comment

ID: 39265356
Follow the link

I can install the libtdsodbc.so. However, run "odbcinst -i -s -f tds.datasource.template" but it can't generate any entry in odbc.ini. Any idea ?

In addition, how to odbc.so in Centos as mentioned in the article ?

LVL 80

Expert Comment

ID: 39267560
The file odbcinst is using is odbcinst.ini
You could try adding the -l /etc/odbc.ini

Reference http://csurs.csr.uky.edu/cgi-bin/man/man2html?1+odbcinst

Author Comment

ID: 39270201
odbcinst -i -s -f tds.datasource.template -l /etc/odbc.ini

It doesn't make any different. File odbc.ini does not created under /etc/

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

LVL 80

Expert Comment

ID: 39270233
I have not used it, but which of your applications/programs rely on odbc.ini and are not working because of that?

There was a commercial ODBC driver and everything relied on the /etc/odbc.ini file for the connection.

your system with freetds has odbcinst.ini which reflects the same set of information.
You could hard link odbcinst.ini to odbc.ini
rm /etc/odbc.ini ; ln /etc/odbcinst.ini /etc/odbc.ini

Author Comment

ID: 39270355
The production server has been setup for PHP to access the SQL Server and I believe we will just follow it.


The FreeTDS connection works fine (with tsql), but I can't access through UnixODBC. It pops out "Unable to connect to data source".
LVL 80

Expert Comment

ID: 39270370
Hard link the odbcinst.ini to odbc.ini and see if that resolves you issue.

Do you have the template you used with odbcinst?

Author Comment

ID: 39270503
Doesn't help.

[root@myweb etc]# cat tds.datasource.template
Driver = FreeTDS
Description = ODBC connection via FreeTDS
Trace = No
Server =
Port = 1433
TDS Version = 8.0

[root@myweb etc]# cat tds.driver.template
Description=v0.63 with protocol v8.0
Driver = /usr/local/lib/libtdsodbc.so
[root@myweb etc]#
LVL 80

Expert Comment

ID: 39270900
Look at odbcinst.ini

Create an entry for the server you want to access there based on example present there.

You have an example how the server has to be defined within either file.
I think, are you working on he basis that running odbcinst will create the appropriate entry for you?

Author Comment

ID: 39271518
odbcinst.ini & odbc.ini have the entry inside. Can't find anything wrong on the entry.

TDS setup should be correct as I can use tsql command to login to the MS SQL. Only the UnixODBC shouldn't be setup but I have review odbc.ini & odbcinst.ini. Can't identify any problem..

[root@myweb ~]# isql -v HPSMS_SRV sa xxxxx
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Unexpected EOF from the server
[01000][unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed
[ISQL]ERROR: Could not SQLConnect
[root@myweb ~]#
LVL 80

Expert Comment

ID: 39271756
odbcinst -i -d -f tds.datasource.template

is this what you have in the odbcinst.ini
Description             = ODBC for PostgreSQL
Driver          = /usr/lib/psqlodbc.so
Setup           = /usr/lib/libodbcpsqlS.so
Driver64                = /usr/lib64/psqlodbc.so
Setup64         = /usr/lib64/libodbcpsqlS.so
FileUsage               = 1

Description             = ODBC for MySQL
Driver          = /usr/lib/libmyodbc5.so
Setup           = /usr/lib/libodbcmyS.so
Driver64                = /usr/lib64/libmyodbc5.so
Setup64         = /usr/lib64/libodbcmyS.so
FileUsage               = 1

Driver          = FreeTDS
Description             = UCLA Registrar (SRDB)
Trace           = No
Server          = srdb.registrar.ucla.edu
Port            = 1433
Create file tds.datasource.template:            =
UsageCount              = 1

Description             = v0.63 with protocol v8.0
Driver          = /usr/lib/libtdsodbc.so
UsageCount              = 1

Is this what you have in freeTDS.conf

#   $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".

# Global settings are overridden by those in a database
# server specific section
        # TDS protocol version
;       tds version = 4.2

        # Whether to write a TDSDUMP file for diagnostic purposes
        # (setting this to /tmp is insecure on a multi-user system)
;       dump file = /tmp/freetds.log
;       debug flags = 0xffff

        # Command and connection timeouts
;       timeout = 10
;       connect timeout = 10

        # If you get out-of-memory errors, it may mean that your client
        # is trying to allocate a huge buffer for a TEXT field.
        # Try setting 'text size' to a more reasonable limit
        text size = 64512

# A typical Sybase server
        host = symachine.domain.com
        port = 5000
        tds version = 5.0

# A typical Microsoft server
        host = ntmachine.domain.com
        port = 1433
        tds version = 7.0

The entries that are added to odbcinst.ini  provide an example on creating note the last two entries in /etc/odbcinst.ini

Author Comment

ID: 39273497
Those settings the the files are correct. Again, TDS works fine but not for UNIXODBC setting. Do I miss anything beside the files mentioned ? Do I miss any system file ?


Description=v0.63 with protocol v8.0

        host =
        port = 1433
        tds version = 8.0

Description=ODBC connection via FreeTDS

tsql result
[root@myweb etc]# tsql -S HPSMS_SRV -U sa -P xxxxxx
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> quit

isql result
[root@myweb etc]# isql -v HPSMS_SRV sa xxxxxx
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[01000][unixODBC][FreeTDS][SQL Server]Unexpected EOF from the server
[01000][unixODBC][FreeTDS][SQL Server]Adaptive Server connection failed
[ISQL]ERROR: Could not SQLConnect
LVL 80

Accepted Solution

arnold earned 2000 total points
ID: 39273529
The error you get is between the interaction of unixodbc and freetds.


suggests including server connection information within odbc.ini
versus bouncing odbc.ini and assuming it will jump to odbcinst.ini to determine the server IP/PORT

odbc.ini following above link example, change yours to:

Description     = HPSMS_SRV

Driver          = TDS

Trace           = Yes

TraceFile       = /tmp/odbc.trace

Database        = SMS

Server          =

Port            = 1433

TDS_Version = 8.0

Open in new window


Author Comment

ID: 39273624
Get the same result.

However, accidentically find out that "TDSVER=8.0 isql HPSMS_SRV root xxxx –v" works fine for my old configuration.

But still looking around how to ingore "TDSVER=8.0" as I don't need that on my production server....
LVL 80

Expert Comment

ID: 39273708
The tds version control the interaction with sql server. Different "Versions" had issued referenced freetds references.

Author Closing Comment

ID: 39273759
Finally, fix the problem by removing a file the odbc.ini under root/.odbc.ini.

Afterwards, it could connect to the SQL server. Thanks for the information anyway.

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question