ODBC Driver 13.1 for Linux Released


Hi all, we are delighted to share the Production Ready Release of the Microsoft ODBC Driver 13.1 for Linux –  (Ubuntu, RedHat and SUSE). The new driver enables access to SQL Server, Azure SQL Database and Azure SQL DW from any C/C++ application on Linux

Added

  • BCP API Support 
    • You can use functions through the ODBC driver as described here on Linux
  • Support for user defined KeyStoreProvider for Always Encrypted
    • You can now user defined/created AE Column Master Key keystore providers. Check out code samples and more information here.
  • Ubuntu 16.10 support
    • Developed a package for Ubuntu 16.10 to ensure an apt-get install experience
  • Dependency on the platform unixODBC Driver Manager instead of the custom unixODBC-utf16 Driver Manager
    • This avoids conflicts with applications/software that depends on the platform unixODBC Driver Manager

Fixed

  • msqobcsql.h  (Connect issues 3115331, 3114970) 
    • Missing definitions for AE, BCP, and SQL Server specific types were added 
  • TRUST_SERVER_CERTIFICATE connection attribute is always yes (Connect 3116639) 
    • Setting the TRUST_SERVER_CERTIFICATE connection attribute to anything other than yes failed to set the attribute value.  This has been corrected. 
  • Fixed Connect issue 2693027 – Memory Leak 
    • We detected this issue independently of the bug report using valgrind.  The memory leak has been fixed.
  • Driver failure when connecting with more than 1024 handles
    • Switched away from libio select. Driver now supports (theoretical) handle limit of 64k or platform max 
  • Intermittent commlinkfailure when using Azure DW 
    • In some high latency scenarios over an encrypted channel, the driver could fail unexpectedly. This has been resolved

Install the ODBC Driver for Linux on Ubuntu 15.10

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/15.10/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql=13.1.4.0-1 mssql-tools=14.0.3.0-1 unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

Install the ODBC Driver for Linux on Ubuntu 16.04

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql=13.1.4.0-1 mssql-tools=14.0.3.0-1 unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

Install the ODBC Driver for Linux on Ubuntu 16.10

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.10/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql=13.1.4.0-1 mssql-tools=14.0.3.0-1 unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

Install the ODBC Driver for Linux on RedHat 6

sudo su
curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo
exit
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
sudo ACCEPT_EULA=Y yum install msodbcsql-13.1.4.0-1 mssql-tools-14.0.3.0-1 unixODBC-devel
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

Install the ODBC Driver for Linux on RedHat 7

sudo su
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo
exit
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
sudo ACCEPT_EULA=Y yum install msodbcsql-13.1.4.0-1 mssql-tools-14.0.3.0-1 unixODBC-devel
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

Install the ODBC Driver for SLES 12

sudo su 
zypper ar https://packages.microsoft.com/config/sles/12/prod.repo 
exit 
sudo ACCEPT_EULA=Y zypper install msodbcsql-13.1.4.0-1 mssql-tools-14.0.3.0-1 unixODBC-devel
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc

Try our Sample

Once you install the driver that runs on a supported Linux distro, you can use this C sample to connect to SQL Server/Azure SQL DB/Azure SQL DW. To download the sample and get started, follow these steps:

wget "https://raw.githubusercontent.com/Microsoft/sql-server-samples/master/samples/tutorials/c/linux/sample_c_linux.c"
gcc sample_c_linux.c -o sample_c_linux -lodbc -w #make sure you change the servername, username and password in the connections string
./sample_c_linux

If you installed the driver using the manual instructions found here, you will have to manually uninstall the ODBC Driver and the unixODBC Driver Manager to use the deb/rpm packages. If you have any questions on how to manually uninstall, feel free to leave a comment below. 

Please fill bugs/questions/issues on our Issues page. We welcome contributions/questions/issues of any kind. Happy programming!

Meet Bhagdev (meetb@microsoft.com)

sql-loves-linux_2_twitter-002

Comments (31)

  1. Keith Erskine says:

    On a brand new Ubuntu 16.04 laptop (“amd64”), when I run “sudo ACCEPT_EULA=Y apt-get install msodbcsql=13.1.4.0-1 mssql-tools=14.0.3.0-1 unixodbc-dev” I get:

    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package msodbcsql
    E: Unable to locate package mssql-tools

    When I try to install the packages separately (as suggested), I still get “Unable to locate package…” errors. Any and all help appreciated!

      1. Keith Erskine says:

        About thirty seconds after I posted my original email, I realized my mistake. I hadn’t run the line “sudo apt-get update”. Once I’d done that, all was well. Sorry about that.

        “If all else fails, read the instructions…”

  2. Maximiliano Schimmel says:

    Hi, this driver can be used by PHP7 on SUSE?
    Can anybody bring me an example? I configured odbc.ini like the older with FreeTDS and now PHP notify me: “odbc_connect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified”
    Thanks and sorry for my english.

    1. Meet Bhagdev says:

      Hi Maximiliano, check out this tutorial (starting section 2): https://www.microsoft.com/en-us/sql-server/developer-get-started/php-sles. It should walk you through steps on how to use PHP + SQL Server on SUSE Linux 12

  3. Amit says:

    I’m installing everything on Ubuntu 16.04 with no problems, but then running your example yields the error:

    “The driver reported the following error SQLAllocHandle(SQL_HANDLE_STMT)”

    what could be going wrong?

    1. Meet Bhagdev says:

      Hi Amit, are you on a 64-bit or 32-bit machine? What version of unixODBC are you running? Can you please file an issue on connect? We will triage it promptly.

  4. Amrit says:

    I have added the packages and the gpg key. apt update shows that packages.microsoft is being fetched from

    When I run “sudo ACCEPT_EULA=Y apt-get install msodbcsql” i get this error: E: Unable to locate package msodbcsql
    I am using ubuntu 16.04

    1. For the benefit of others who may run into this issue, the repository and the ms sql odic driver is 64 bit only. i.e. the command dpkg –print-architecture should show amd64 and NOT i386 (which is 32 bit). This can lead to the error package not found even though the repository gets added correctly

    2. Meet Bhagdev says:

      Are you running on 32bit or 64bit?

  5. D says:

    Hello,
    when installing on rhel6 either 13.0 or 13.1 there is glibc_2.14 dependency which does not exists on rhel6 [“RHEL 6 is based off version 2.12, and at present there are no plans for 2.14 support in RHEL 6.” From Red Hat:
    https://access.redhat.com/solutions/755003
    :

    —> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
    —> Package msodbcsql.x86_64 0:13.1.4.0-1 will be installed
    –> Processing Dependency: libc.so.6(GLIBC_2.14)(64bit) for package: msodbcsql-13.1.4.0-1.x86_64
    –> Finished Dependency Resolution
    Error: Package: msodbcsql-13.1.4.0-1.x86_64 (packages-microsoft-com-prod)
    Requires: libc.so.6(GLIBC_2.14)(64bit)

    looks like it’s build on rhel7 and then back ported?

    1. Meet Bhagdev says:

      I think you selected the wrong repo. Our RedHat6 repo has the RedHat 6 package that was built natively.

      Can you try the following:

      sudo su
      curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo
      exit
      sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
      sudo ACCEPT_EULA=Y yum install msodbcsql-13.1.4.0-1 mssql-tools-14.0.3.0-1
      echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
      echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
      source ~/.bashrc

      1. D says:

        Thank you Bhagdev — looks like RHEL 6.5 works but 6.8 has trouble and complaints though could be something else. Something i believe worth while mention is that pre-check you’re doing — odbcinst -q -d -n “ODBC Driver 13 for SQL Server” — complaints if odbcini is managed centrally and pushed via puppet to a host where driver(s) might not be installed.

  6. BK says:

    We down loaded below 3 files from “https://packages.microsoft.com/rhel/7/prod/” on Linux 7.3 Red hat server
    msodbcsql-13.1.4.0-1
    mssql-tools-14.0.3.0-1
    unixODBC-utf16-2.3.1-1.x86_64.rpm

    BCP commands used:
    export PATH=$PATH:/opt/mssql-tools/bin
    export PATH=$PATH:/opt/mssql-tools/bin
    /opt/mssql-tools/bin/bcp DB_NAME.dbo.Test_Table out /tmp/bcp_out.txt -S Server_name -U login_Name -P Password -c -t”,”

    After above statement, BCP execution getting “Memory Fault” message.
    There is no output file generating like /tmp/bcp_out.txt

    SQLCMD working fine and have issue with BCP command.Please advise.

    Is this bug or is something we are missing to install.

  7. sm says:

    I get the same error

    1. Meet Bhagdev says:

      This should now be fixed!

  8. stavro says:

    i am getting the same error. repo is added.

    1. Meet Bhagdev says:

      This should now be fixed!

  9. shafesyed says:

    hello
    Is ODBC Driver 13 for linux is compatible with linux 11.4? which version of unixODBC is supported?
    ss

    1. Meet Bhagdev says:

      The Microsoft ODBC Driver 13.1 is compatible with Ubuntu 15.10, 16.04, 16.10, Redhat 6, 7 and SLES 12. unixODBC 2.3.1 is supported

  10. xscence says:

    When i run “sudo ACCEPT_EULA=Y apt-get install msodbcsql=13.1.4.0-1 ” i get this error: E: Unable to locate package msodbcsql
    im using ubuntu 16.04

    1. Meet Bhagdev says:

      Did you add the packages.microsoft.com repository?

      1. xscence says:

        How i could do this ?

      2. xscence says:

        I follow the example above for the ubuntu 16.04

      3. Suraj Bharech says:

        I am also getting the same error. I added packages.microsoft.com repository as mentioned.
        root@asdfssd:~# sudo ACCEPT_EULA=Y apt-get install msodbcsql=13.1.4.0-1 mssql-tools-14.0.3.0-1 unixodbc-dev
        Reading package lists… Done
        Building dependency tree
        Reading state information… Done
        E: Unable to locate package mssql-tools-14.0.3.0-1
        E: Couldn’t find any package by glob ‘mssql-tools-14.0.3.0-1’
        E: Couldn’t find any package by regex ‘mssql-tools-14.0.3.0-1’

      4. Suraj Bharech says:

        In fact, I am getting error because public key is not available.

        W: GPG error: https://apt-mo.trafficmanager.net/repos/mssql-ubuntu-xenial-release xenial InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY B02C46DF417A0893
        W: The repository ‘https://apt-mo.trafficmanager.net/repos/mssql-ubuntu-xenial-release xenial InRelease’ is not signed.
        N: Data from such a repository can’t be authenticated and is therefore potentially dangerous to use.
        N: See apt-secure(8) manpage for repository creation and user configuration details.

      5. AT says:

        I have the same problem. Ubuntu 16.04.
        and I had the packages.microsoft.com repository added to the /etc/apt/sources.list.d/mssql-release.list

      6. Meet Bhagdev says:

        Can you try installing msodbcsql and mssql-tools separately? In different apt-get commands.
        apt-get install msodbcsql
        apt-get install mssql-tools

    2. AT says:

      Hi Xscence,

      Did you solve the problem? could you please share the note if so? thank you

      1. Meet Bhagdev says:

        Let me try these steps on a fresh machine and get back to you.

      2. Meet Bhagdev says:

        This should now be fixed!

Skip to main content