Do you need tools and libraries to use MSQ SQL Server from your Linux box ?
Have you tried using UnixODBC and FreeDTS ?
Let’s see how to do this if you choose to compile and build those libraries.
First of all you need to download from here the last version of UnixODBC and FreeDTS sources.
After the download is complete switch to root user, extract files and open the directory created in the process.
You should see:
– directory freedts
– directory unixodbc
– file build_for_others.sh
– file build_for_slackware.sh
If you’re using Slackware (i prepared the package using a Slackware64-current box) you only have to execute build_for_slackware.sh .
If you’re not using a Slackware box you have to execute build_for_others.sh , this script will install UnixODBC into /opt/unixodbc and FreeDTS into /opt/freedts.
During the build process pay attention to missing libraries and install them.
When everything is done and packages are installed you can begin the real database connections configuration.
Basic configurations for FreeDTS have to be put into /etc/freedts.conf (Slackware) or /opt/freedts/etc/freedts.conf (not Slackware); the file is divided in sections, one for each server, containing:
– unique connection id (between square brackets)
– server name or ip address
– tcp port
– connection version, 8.0 shoul be ok
Here an example of freedts.conf:
1 2 3 4 |
[MYSERVER] host = myserver.mydomain.com port = 1433 tds version = 8.0 |
Configured FreeDTS it’s time to configure UnixODBC, editing file /etc/odbcinst.ini (or /opt/unixodbc/etc/odbcinst.ini if not using Slackware) and /etc/odbc.ini (or /opt/unixodbc/etc/odbc.ini if not using Slackware).
File odbcinst.ini has to contain data related to FreeDTS; the file is divided in sections, each of them containing::
– unqiue string identifiying the driver (between square brackets)
– a simple description
– the location of the driver .so file
– logs information
Here an example of odbcinst.conf (Slackware64)
1 2 3 4 5 6 7 |
[FreeTDS] Description=Microsoft SQL Server FreeTDS Driver Driver=/usr/lib64/libtdsodbc.so Trace = Yes TraceFile = /tmp/freetds.log FileUsage = 1 UsageCount =1 |
Here an example of odbcinst.conf (Slackware 32bit)
1 2 3 4 5 6 7 |
[FreeTDS] Description=Microsoft SQL Server FreeTDS Driver Driver=/usr/lib/libtdsodbc.so Trace = Yes TraceFile = /tmp/freetds.log FileUsage = 1 UsageCount =1 |
Here an example of odbcinst.conf (other distros)
1 2 3 4 5 6 7 |
[FreeTDS] Description=Microsoft SQL Server FreeTDS Driver Driver=/opt/freedts/lib/libtdsodbc.so Trace = Yes TraceFile = /tmp/freetds.log FileUsage = 1 UsageCount =1 |
The last file to edit is odbc.ini , telling to the system which driver and server name use for a specific datasource:
– datasource unique name (between square brackets)
– server name (as used in freedts.conf)
– driver unique name (as used in odbcinst.ini)
Example of odbc.conf .
1 2 3 |
[MYSERVER] ServerName = MYSERVER Driver = FreeTDS |
When everything is installed and configured you will be able to connect to your SQL Server, from command line you can use isql (or /opt/unixodbc/bin/isql if not using Slackware), specifying datasource, username and password:
1 |
isql MYSERVER USERNAME PASSWORD |