search
top

How To Install Microsoft SQL drivers and unixODBC 2.3.0 on RHEL 6 64 bit

How To Install Microsoft SQL drivers and unixODBC 2.3.0 on RHEL 6 64 bit

Microsoft’s SQL drivers can not use the 2.2.14 unixODBC installed with RedHat 6. It requires 2.3.0 which requires compiling and installing from source.

First download the latest unixODBC from http://www.unixodbc.org/ . Put tarball in /tmp and extract.

Extract the tar ball

# tar xvzf unixODBC-2.3.0.tar.gz

Change to the unixODBC-2.3.0 directory adn set a few compiler variables, configure, make and install the code.

At a command prompt, execute the command:

# CPPFLAGS=”-DSIZEOF_LONG_INT=8″
# export CPPFLAGS.
# ./configure –prefix=/usr –libdir=/usr/lib64 –sysconfdir=/etc –enable-gui=no –enable-drivers=no –enable-iconv –with-iconv-char-enc=UTF8 –with-iconv-ucode-enc=UTF16LE
# make
# make install

Download MS SQL Odbc drivers
Download the msodbcsql-11.0.2270.0.tar.gz from http://www.microsoft.com/en-us/download/details.aspx?id=36437  drivers. Copy msodbcsql-11.0.2270.0.tar.gz to /tmp.

Install a few requirements.
ODBC driver for 64-bit Red Hat Enterprise Linux 5 requires the following packages:
glibc
libgcc
libstdc++
e2fsprogs-libs
krb5-libs
openssl

Make sure that you have root permission.

Change to the directory where the ODBC driver on Linux placed the file called msodbcsql-11.0.2270.0.tar.gz. Make sure that you have the *.tar.gz file that matches your version of Linux. To extract the files, execute the following command, tar xvzf msodbcsql-11.0.2270.0.tar.gz.

Change to the msodbcsql-11.0.2270.0 directory and there you should see a file called install.sh.
To see a list of the available installation options, execute the following command: ./install.sh install.

Enter YES to accept the license or anything else to terminate the installation: YES

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
Microsoft ODBC Driver 11 for SQL Server files copied …………………… OK
Symbolic links for bcp and sqlcmd created …………………………….. OK
Microsoft ODBC Driver 11 for SQL Server registered ………………. INSTALLED

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

Make a backup of odbcinst.ini. The driver installation updates /etc/odbcinst.ini. odbcinst.ini contains the list of drivers that are registered with the unixODBC Driver Manager. To discover the location of odbcinst.ini on your computer, execute the following command: odbc_config –odbcinstini.

Before you install the driver, execute the following command: ./install.sh verify. The output of ./install.sh verify reports if your computer has the required software to support the ODBC driver on Linux.

When you are ready to install the ODBC driver on Linux, execute the command: ./install.sh install. If you need to specify an install command (bin-dir or lib-dir), specify the command after the install option.

After reviewing the license agreement, type YES to continue with the installation.

Installation puts the driver in /opt/microsoft/msodbcsql/11.0.2270.0. The driver and its support files must be in /opt/microsoft/msodbcsql/11.0.2270.0.

To verify that the ODBC driver on Linux was registered successfully, execute the following command: odbcinst -q -d -n “ODBC Driver 11 for SQL Server”.

[ cvgldcognos11 etc ] # odbcinst -q -d -n “ODBC Driver 11 for SQL Server”
[ODBC Driver 11 for SQL Server]
Description=Microsoft ODBC Driver 11 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-11.0.so.2270.0
Threading=1
UsageCount=1

To add drivers:
The value passed to the Driver keyword can either be:
•    The name you used when you installed the driver. Or,
•    The path to the driver, which was specified in the template .ini file used to install the driver.
To create a DSN, create (if necessary) and edit the file ~/.odbc.ini (odbc.ini in your home directory). The following is a sample file that shows the required entries for a DSN:

[MSSQLTest]
Driver = ODBC Driver 11 for SQL Server
Server = [protocol:]server[,port]
#
# Note:
# Port is not a valid keyword in the ~/.odbc.ini file
# for the Microsoft ODBC driver on Linux
#

You can optionally specify the protocol and port to connect to the server. For example, Server = tcp:servername,12345.
To connect to a named instance on a static port, use Server = servername,port_number. Connecting to dynamic port is not supported.
Optionally, you can add the DSN information to a template file and execute the following command: odbcinst -i -s -f template_file
You can verify that your driver is working by using isql to test the connection. Or, you can use this command: bcp master.INFORMATION_SCHEMA.TABLES out OutFile.dat -S <server> -U <name> -P <password>

2 Responses to “How To Install Microsoft SQL drivers and unixODBC 2.3.0 on RHEL 6 64 bit”

  1. Mahesh says:

    Have you tried creating a rpm for this odbc driver install? If so, can you provide the SPEC file ?

  2. AngelSensei says:

    Thanks it worked for me.!!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

top