Installing the Microsoft ODBC Driver for SQL Server on Linux

Installing the Microsoft ODBC Driver for SQL Server on Linux

SQL Server 2012

This topic explains how to install the Microsoft ODBC Driver 11 for SQL Server on Linux. Before you can begin to use the driver, install the unixODBC driver manager. See Installing the Driver Manager for more information.


These instructions refer to msodbcsql-11.0.2270.0.tar.gz, which is installation file for Red Hat Linux. If you are installing the CTP for SUSE Linux, the file name is msodbcsql-11.0.2260.0.tar.gz.

To install the driver:

  1. Make sure that you have root permission.

  2. 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.

  3. Change to the msodbcsql-11.0.2270.0 directory and there you should see a file called

  4. To see a list of the available installation options, execute the following command: ./

  5. Make a backup of odbcinst.ini. The driver installation updates 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.

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

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

  8. 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".

Use Existing MSDN C++ ODBC Samples for the ODBC Driver on Linux shows a code sample that connects to SQL Server using the ODBC driver on Linux.

If you are unable to make a connection to SQL Server using the ODBC driver on Linux, use the following information to identify the problem.

The most common connection problem is to have two copies of the UnixODBC Driver Manager installed. Search /usr for libodbc*.so*. If you see more than one version of the file, you (possibly) have more than one driver manager installed. Your application might use the wrong version. If you see the UnixODBC Driver Manager installed package when you execute (on Red Hat) the command yum list unixODBC, delete the package.

Enable the connection log by verifying that your odbcinst.ini file contains the section and these items:

Trace = Yes
TraceFile = (your log file)

If you get another connection failure and do not see a log file, there (possibly) are two copies of the driver manager on your computer. Otherwise, the log output should be similar to the following:

            Connection = 0x17c858e0
            Window Hdl = (nil)
            Str In = [DRIVER={ODBC Driver 11 for SQL Server};SERVER={};Trusted_Connection={YES};WSID={};AP...][length = 139 (SQL_NTS)]
            Str Out = (nil)
            Str Out Max = 0
            Str Out Ptr = (nil)
            Completion = 0
        UNICODE Using encoding ASCII 'UTF8' and UNICODE 'UTF16LE'

If the character encoding is not UTF-8, for example:

UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'

There is more than one Driver Manager installed and your application is using the wrong one. Or, the Driver Manager was not built correctly.

For more information about resolving connection failures, see:

You can uninstall the ODBC driver on Linux, by executing the following commands:

  1. rm -f /usr/bin/sqlcmd

  2. rm -f /usr/bin/bcp

  3. rm -rf /opt/microsoft/msodbcsql

  4. odbcinst -u -d -n "ODBC Driver 11 for SQL Server"

© 2015 Microsoft