Packetwatch.net

Microsoft ODBC for MSSQL in Red Hat Enterprise Linux



Last modified: Nov. 11, 2013

Contents
1 - Summary
2 - System variables
3 - Driver installation
4 - ODBC configuration
5 - ODBC testing


1 - Summary

This guide will show how to install the Microsoft ODBC driver for SQL Server in
Red Hat Enterprise Linux. This has been tested in Red Hat Enterprise Linux 6
(x86_64).


2 - System variables

Log in as a normal user. Add these lines to /etc/profile. This will set the
variables on system start up.
  ODBCSYSINI=/etc
  ODBCINI=/etc/odbc.ini
  export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE ODBCSYSINI ODBCINI INPUTRC LD_LIBRARY_PATH
# sudo cp /etc/profile /etc/profile.example
[sudo] password for testuser:
# sudo vi /etc/profile
[sudo] password for testuser:

Set the following variables as the root user.
# su - root
Password:
# ODBCSYSINI=/etc
# echo $ODBCSYSINI
/etc
# ODBCINI=/etc/odbc.ini
# echo $ODBCINI
/etc/odbc.ini
# logout


3 - Driver installation

Download the driver from Microsoft and then install it. Here are some links.
  http://msdn.microsoft.com/en-us/library/hh568451.aspx
  http://www.microsoft.com/en-us/download/details.aspx?id=36437
# mkdir odbc_mssql
# cd odbc_mssql/
# wget http://.../msodbcsql-11.0.2270.0.tar.gz
# tar -zxvf msodbcsql-11.0.2270.0.tar.gz
# cd msodbcsql-11.0.2270.0/
# ./build_dm.sh
# cd /tmp/unixODBC.12188.19504.88/unixODBC-2.3.0/
# sudo make install
[sudo] password for testuser:
# cd ~/msodbcsql-11.0.2270.0/
# odbc_config --odbcinstini
/etc/odbcinst.ini
# ./install.sh verify

Microsoft ODBC Driver 11 for SQL Server Installation Script
Copyright Microsoft Corp.

Starting install for Microsoft ODBC Driver 11 for SQL Server

Checking for 64 bit Linux compatible OS ..................................... OK
Checking required libs are installed ........................................ OK
unixODBC utilities (odbc_config and odbcinst) installed ..................... OK
unixODBC Driver Manager version 2.3.0 installed ............................. OK
unixODBC Driver Manager configuration correct .............................. OK*
Microsoft ODBC Driver 11 for SQL Server already installed ............ NOT FOUND

Install log created at /tmp/msodbcsql.9649.15582.15964/install.log.


4 - ODBC configuration

One or more steps may have an *. See README for more information regarding
these steps.
# sudo cp /etc/odbcinst.ini /etc/odbcinst.ini.example
[sudo] password for testuser:
# sudo ./install.sh install
[sudo] password for testuser:
# odbcinst -q -d -n "ODBC Driver 11 for SQL Server"

Here is an example entry that will use the ODBC driver for SQL Server.
  [testdb]
  Driver          = ODBC Driver 11 for SQL Server
  Trace           = Yes
  Server          = X.X.X.X
  Port            = 1433
  Database        = testdb
# sudo vi /etc/odbc.ini
[sudo] password for testuser:


5 - ODBC testing

Test out the ODBC connection.
# isql -v testdb $username $password
SQL> select count(*) from testtable;
SQL> quit


Last modified: Thu Jan 1 00:00:00 1970 UTC
Packetwatch Research 2002-2024.