Tag Archives: sql

Microsoft-SQL-Server

How To Install Microsoft SQL Server ODBC Driver for Linux on Ubuntu Server

UPDATE: I’ve included a list of items to consider when connecting to a Microsoft SQL Server from Linux here. Please review this if you’re starting out and don’t fully understand your possibly choices (using your programming language of choice’s driver, using the Microsoft ODBC driver for linux, or possibly using an open-source driver such as freetds).

UPDATE 2: I’ve included a new link to a tutorial I wrote on how to install an updated unixODBC on Ubuntu Server.

Need to connect to a Microsoft SQL Server on Linux? Your best bet is to use their ODBC drivers (available here) – but OH NO – they’re only supported via Red Hat Enterprise Linux.

No fear – of course they’ll work on most 64bit distributions.

Install Instructions for Ubuntu Server 12.10 – this should actually work for most Debian/Ubuntu distributions that have packages available for openssl-1.0.0 and unixODBC 2.3.0 (though you may want to download and install 2.3.2 for better performance):

The following numbered steps have become mostly unnecessary. I’ve fixed the Microsoft scripts so you no longer have to use “–force” to install the driver on Ubuntu and create all the symlinks yourself.
Those fixed scripts are available here: Microsoft SQL Server ODBC Driver 1.0 for Linux Fixed Install Scripts.
To use the modified scripts you can:

To install the driver manually:

  1. Visit http://www.microsoft.com/en-us/download/details.aspx?id=36437 and download the file for “RedHat6\msodbcsql-11.0.2270.0.tar.gz”. Currently you can use the following command until the link changes:
    $ wget http://download.microsoft.com/download/B/C/D/BCDD264C-7517-4B7D-8159-C99FC5535680/RedHat6/msodbcsql-11.0.2270.0.tar.gz
  2. Extract the tarball:  tar -zxvf msodbcsql-11.0.2270.0.tar.gz
  3. Download and Install unixODBC 2.3.0+ if you haven’t already
  4. change to the new directory ( cd sqlncli-11.0.1790.0 ) and run the install script:
    sudo bash install.sh install --accept-license --force
  5. make sure the SQL Server dependencies are installed:
    sudo apt-get install openssl libkrb5-3 libc6 e2fsprogs
  6. Create some symlinks so everything works with the paths these binaries are expecting to find libraries:
    • sudo ln -s /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /usr/lib/x86_64-linux-gnu/libcrypto.so.10;
    • sudo ln -s /lib/x86_64-linux-gnu/libssl.so.1.0.0 /usr/lib/x86_64-linux-gnu/libssl.so.10;
    • sudo ln -s /usr/lib/x86_64-linux-gnu/libodbcinst.so.2.0.0 /usr/lib/x86_64-linux-gnu/libodbcinst.so.1;
    • sudo ln -s /usr/lib/x86_64-linux-gnu/libodbc.so.2.0.0 /usr/lib/x86_64-linux-gnu/libodbc.so.1

And that should be it. The last two steps are dependent on unixODBC-2.3.1 or higher. If you’re using 2.3.0 (please upgrade) you’ll need to link against the “1.0.0” libraries.

Test your install by connecting to your server using sqlcmd (sqlcmd -S my.sql.server.com -U username) to make sure everything is ok. You should now be able to configure ODBC to use the MS SQL ODBC Driver for Linux on Ubuntu.

Yes – in that last steps we’re creating  symlinks from “2.0.0” with a link names “.so.1” – masquerading as the older version 1 doesn’t seem to hurt anything in any of my installations. According to the unixODBC changelog: “Major change is to change the library version number from 1 to 2 to signal the SQLLEN change for 64 land. Should have been done for 2.3.0, but better late than never. So if after installing you have apps that can’t find libodbc.so, its likely they are linked to libodbc.so.1, so just create a symlink from libodbc.so.2”

So I think we’re OK.