This topic will explain how to install the Microsoft SQL Server ODBC Driver for Linux. Before you can begin to use the driver, you will first need to install the unixODBC driver manager. See Installing the Driver Manager for more information.
Installation Steps
To install the driver:
Make sure you have root permission.
Change to the directory where the SQL Server ODBC Driver placed the file called sqlncli-11.0.1790.0.tar.gz (make sure that you have the *.tar.gz file that matches your version of Red Hat Enterprise Linux). Run the following command to extract the files: tar xvzf sqlncli-11.0.1790.0.tar.gz.
Change to the sqlncli-11.0.1790.0 directory and there you should see a file called install.sh. You can run install.sh to install the SQL Server ODBC Driver for Linux.
Execute the following command to see a list of the available options: ./install.sh.
You may want to make a backup of odbcinst.ini. The driver installation will update odbcinst.ini. odbcinst.ini contains the list of drivers that are registered with the unixODBC Driver Manager. Execute the following command to discover the location of odbcinst.ini on your computer: odbc_config --odbcinstini.
Before you install the driver, execute the following command: ./install.sh verify. The output of ./install.sh verify will indicate if your computer has the required software to support the SQL Server ODBC Driver for Linux.
When you are ready to install the SQL Server ODBC Driver for 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.
The driver will be installed in /opt/Microsoft/sqlncli/11.0.1790.0. For version 1, the driver is required to be in /opt/Microsoft/sqlncli/11.0.1790.0.
Run the following command to verify that the SQL Server ODBC Driver for Linux was registered successfully: odbcinst -q -d -n "SQL Server Native Client 11.0"
Use Existing MSDN C++ ODBC Samples for Microsoft Linux ODBC Driver shows a code sample that connects to SQL Server using the SQL Server ODBC Driver for Linux.
Troubleshooting Connection Problems
If you are unable to make a connection to SQL Server using the SQL Server ODBC Driver for Linux, the following information may help you 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 may have more than one driver manager installed and your application may be using the wrong version. Another problem could be if you see the UnixODBC Driver Manager installed package when you execute the command yum list unixODBC.
Enable the connection log by verifying that your odbcinst.ini file contains the section and items listed below:
![]() | |
---|---|
[ODBC] Trace = Yes TraceFile = (your log file) |
If you enable the connection log and get another connection failure, and if you do not see a log file, there may be two copies of the driver manager on your computer. Otherwise, the log output should be similar to the following:
![]() | |
---|---|
[ODBC][28783][1321576347.077780][SQLDriverConnectW.c][290] Entry: Connection = 0x17c858e0 Window Hdl = (nil) Str In = [DRIVER={SQL Server Native Client 11.0};SERVER={algsql.sys-sqlsvr.local,2866};Trusted_Connection={YES};WSID={alg_rhel6};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 might be more than one Driver Manager installed and your application is not using the one required by the SQL Server ODBC Driver for Linux. Or, the Driver Manager was not built correctly.
For more information about resolving connection failures, see:
Connectivity troubleshooting in SQL Server 2008 with the Connectivity Ring Buffer
The error number specified in the URL (11001) should be changed to match the error that you see.
Uninstalling the SQL Server ODBC Driver for Linux
You can uninstall the SQL Server ODBC Driver for Linux, by executing the following commands:
rm –f /usr/bin/sqlcmd
rm –f /usr/bin/bcp
rm –rf /opt/Microsoft/sqlncli
odbcinst –u –d –n "SQL Server Native Client 11.0"