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.


Posted

in

, , ,

by

Tags:

Comments

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

  1. tgarriz Avatar
    tgarriz

    GREAT GREAT GREAT!!!
    THANK YOU!!

  2. w0rks Avatar
    w0rks

    You’re the man!! This saved me a bunch of time tracking down the issue!

  3. Snickers Avatar
    Snickers

    Thanks. Was able to get it working on Debian Stretch.

  4. stupid dog Avatar
    stupid dog

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

  5. pmateusz Avatar
    pmateusz

    Many thanks! You save great deal of my time.

  6. rube Avatar
    rube

    You’re awesome!

    1. Jason Avatar
      Jason

      Thanks!

  7. Rodrigo Hernan Ramos Avatar
    Rodrigo Hernan Ramos

    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

  8. Rodrigo Hernan Ramos Avatar

    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

  9. web Avatar
    web

    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

  10. Daniel Walters Avatar
    Daniel Walters

    i just want to say thanks for solving this problem. the file has moved location now but your process was invaluable.
    I opened a stackoverflow ticket documenting the new location.
    https://stackoverflow.com/questions/47180843/python-cant-open-lib-libtdsodbc-so-file-not-found

    1. Jason Avatar
      Jason

      Thanks Daniel

  11. Rahul Bafna Avatar
    Rahul Bafna

    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

    1. Jason Avatar
      Jason

      I’m sorry, I’m not aware of any way to fix this.

Leave a Reply

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