MSSQL ODBC Client on Debian 9 Stretch


Many years ago fREW Schmidt wrote a very handy article on installing MSSQL ODBC drivers in debian. Since then Microsoft have improved their support of debian somewhat and things have changed making it easier to install, however they still (as at 2017-11-06) have not released proper drivers for Debian Stretch.
Add the microsoft repo

echo 'deb [arch=amd64] https://packages.microsoft.com/debian/8/prod jessie main' > /etc/apt/sources.list.d/mssql-release.list

Add the key

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -

then update and install

sudo apt update
sudo apt install msodbcsql mssql-tools

If you try and connect to sql now you get an obscure error like this:

/opt/mssql-tools/bin/sqlcmd -S 10.0.2.13 -U xxx -P yyy
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Can't open lib '/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9.1' : file not found.

But the file exists:

$ file /opt/mssql-tools/bin/sqlcmd
/opt/mssql-tools/bin/sqlcmd: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=21a353af470e7849544daab892ec9b1bfc36dc87, not stripped

This somewhat misleading error is actually due to the libmsodbcsql lib being linked against a very specific version of libssl. Check the output of ldd:

$ ldd /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9.1 | grep 'not found'
libcrypto.so.1.0.0 => not found
libssl.so.1.0.0 => not found

But it turns out this can easily be solved by manually installing the libssl package from Debian Jessie:

wget "http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb"
sudo apt install ./libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb

then you should be back in business.

, , ,

14 responses to “MSSQL ODBC Client on Debian 9 Stretch”

  1. Finally, shame on me that it took me 2h to find your post. But again – MANY THANKS!

  2. Gracias!
    actualizarón el paquete de lib.
    ahora es:
    sudo wget “http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u9_amd64.deb”
    sudo apt install ./libssl1.0.0_1.0.1t-1+deb8u9_amd64.deb

  3. Hi Thanks
    now is
    sudo wget “http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u9_amd64.deb”
    sudo apt install ./libssl1.0.0_1.0.1t-1+deb8u9_amd64.deb

  4. Hey,
    i cant find the packages msodbcsql and mssql-tools.
    E: Paket msodbcsql kann nicht gefunden werden.
    E: Paket mssql-tools kann nicht gefunden werden.
    There are only amd64 packages.
    msodbcsql17:amd64{ab} mssql-tools:amd64{b}
    But i cant install them. Can someone help me?
    Greetz
    web

  5. Is it possible to install ODBC Driver on Debian 9 as of today? Your thread above seems to discuss about the Raspberry OS not compatible with Debian 9 as of 2017. We are facing lot of issues while installing odbc driver for debian9 Stretch for our raspberry pi 3b+ model.
    Apparently no other temporary driver works either. Do you suggest some interim fix so that we can connect MSSQL from raspberry pi

Leave a Reply

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