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
  • 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
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 (54)

  1. John Gillis says:

    It appears the 13.1 Microsoft driver for LINUX has a fatal bug in that it cannot handle high order bit characters which are at the end of a character field when a significant volume is passed through the bulk load facility. Unfortunately the reason to convert to this driver is primarily the bulk load facility.

    1. Meet Bhagdev says:

      Hi John, We will work with you to get this resolved. Let’s continue the conversation offline.

  2. m chen says:

    Linux RedHat 7
    input:
    % sudo ACCEPT_EULA=Y yum install msodbcsql-13.1.4.0-1 mssql-tools-14.0.3.0-1 unixODBC-devel

    got:
    No package msodbcsql-13.1.4.0-1 available.
    No package mssql-tools-14.0.3.0-1 available.

    wandering why?
    Thanks

    1. Meet Bhagdev says:

      Hello m chen, happy to look into this. Can you confirm that you added the Microsoft packages repository?

      Can you share the output of ls /etc/yum.repos.d

  3. Mohammed says:

    https://packages.microsoft.com/debian/8/prod/ does not contain package for mssql-tools

    1. Meet Bhagdev says:

      Hi Mohammed, we are working on the mssql-tools package. We will keep you posted!

  4. Patrick Shroads says:

    Hello,

    I have been using sqlcmd-13.0.0.0 to connect successfully from a CentOS box to a SQL Server 2012 server for over a year. Over the weekend we migrated to a new SQL Server box where the version of SQL Server remained the same but the OS went from Windows 2008 R2 to Windows 2012 R2. I am now no longer able to connect to SQL Server. I get:

    Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
    Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: Error code 0x2AF9.
    Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..

    I have verified that the username and password are correct by connecting via Management Studio from another server. I have also verified that I can telnet from the linux host to SQL Server’s listening port to rule out networking issues.

    Any ideas?

    Thanks

    1. Meet Bhagdev says:

      Are you able to connect using other command line tools/drivers from CentOS? We can try using isql and mssql. This will eliminate the network problem completely?

  5. Keith Lee says:

    Hi Bhagdev,
    I’m attempting the driver install on Debian 8

    First attempt was using the Ubuntu instructions
    “`
    The following packages have unmet dependencies:
    msodbcsql : Depends: libc6 (>= 2.21) but 2.19-18+deb8u9 is to be installed
    Depends: unixodbc-utf16 (>= 2.3.1-1) but it is not going to be installed
    mssql-tools : Depends: libc6 (>= 2.21) but 2.19-18+deb8u9 is to be installed
    Depends: libstdc++6 (>= 5.2) but 4.9.2-10 is to be installed
    E: Unable to correct problems, you have held broken packages.
    “`
    (unixodbc-dev is installed, debian 8 has no package unixodbc-dev-utf16)

    No problem, this was half expected, I noted that there was a Jessie repo too so I updated the source.list file, then updated etc

    `deb [arch=amd64] https://packages.microsoft.com/debian/8/prod jessie main`

    “`
    sudo ACCEPT_EULA=Y apt-get install msodbcsql mssql-tools
    E: Unable to locate package mssql-tools
    “`

    Still the driver installed, which was all I’m after.
    I then gave the sample_c_linux.c a go, which compiled fine
    but reports:
    “`
    terminate called after throwing an instance of ‘std::runtime_error’
    what(): locale::facet::_S_create_c_locale name not valid
    Aborted
    “`
    at run time.

    I have a bit of work to do before I can try out pyodbc; the reason for the install, this may be later in the week.

    1. Meet Bhagdev says:

      Can you try these steps on a fresh Debian 8 machine?

      sudo su
      curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add –
      curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list
      exit
      sudo apt-get update
      sudo ACCEPT_EULA=Y apt-get -y install msodbcsql

      You error is mostly likely because you tried installing the Ubuntu driver on Debian 8.

      1. dataviznz says:

        Hi,
        I had the same issues on Debian 8 (Jessie) and followed your advice. Most of the dependency mentions are gone now, but only this one remains:

        The following packages have unmet dependencies:
        msodbcsql : Depends: libc6 (>= 2.21) but 2.19-18+deb8u9 is to be installed

        What can I do to fix it? Thanks!

      2. Meet Bhagdev says:

        What steps did you follow for Debian Jessie? Seems like apt-get did not resolve the dependencies.

  6. Jose Ochoa says:

    I have a Linux 6.8 server that appears to not install the 13.1 driver. Please advise.

    #-> ACCEPT_EULA=Y yum install msodbcsql-13.1.4.0-1 mssql-tools-14.0.3.0-1 unixODBC-devel
    Loaded plugins: product-id, search-disabled-repos, security, subscription-manager
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Setting up Install Process
    Resolving Dependencies
    –> Running transaction check
    —> Package msodbcsql.x86_64 0:13.1.4.0-1 will be installed
    –> Processing Dependency: unixODBC >= 2.3.1 for package: msodbcsql-13.1.4.0-1.x86_64
    –> Processing Dependency: libodbcinst.so.2()(64bit) for package: msodbcsql-13.1.4.0-1.x86_64
    —> Package mssql-tools.x86_64 0:14.0.3.0-1 will be installed
    —> Package unixODBC-devel.x86_64 0:2.3.1-4.el6 will be installed
    –> Running transaction check
    —> Package unixODBC.x86_64 0:2.3.1-4.el6 will be installed
    –> Finished Dependency Resolution

    Dependencies Resolved

    =========================================================================================================
    Package Arch Version Repository Size
    =========================================================================================================
    Installing:
    msodbcsql x86_64 13.1.4.0-1 packages-microsoft-com-prod 5.6 M
    mssql-tools x86_64 14.0.3.0-1 packages-microsoft-com-prod 250 k
    unixODBC-devel x86_64 2.3.1-4.el6 packages-microsoft-com-prod 56 k
    Installing for dependencies:
    unixODBC x86_64 2.3.1-4.el6 packages-microsoft-com-prod 942 k

    Transaction Summary
    =========================================================================================================
    Install 4 Package(s)

    Total size: 6.8 M
    Installed size: 6.8 M
    Is this ok [y/N]: y
    Downloading Packages:

    Package unixODBC-devel-2.3.1-4.el6.x86_64.rpm is not signed

    1. Meet Bhagdev says:

      Can you try these steps and let me know if it works:
      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. Jose Ochoa says:

        Thank you for the quick response. I used the nogpgcheck option and was able to complete the installation. I successfully tested the driver using isql utility as well at the application level (SAS).

  7. al says:

    Hi, with the most recent version of your install steps you moved the dependency from the custom built unixODBC-utf16 and unixODBC-utf16-devel to the base packages available directly from the distribution. This is a good direction to head in, however, in RHEL7’s case doing this also breaks support for UTF8/UTF16LE (seems to only support ASCII ISO8859-1) because the unixODBC packages available from the Red Hat repositories are not built with ‘–enable-iconv –with-iconv-char-enc=UTF8 –with-iconv-ucode-enc=UTF16LE’ at compile time. Are there any plans to address this? If so what are they?

    1. Meet Bhagdev says:

      There are not plans to support this at this time. We now no longer use a custom (utf-16) Driver Manager. We are using the system shipped Driver Manager to make sure we don’t break support agreements.

  8. David Howell says:

    I’ve managed to install this on a redhat-like distro that uses priorities plugin for yum.
    Modified this line to disable the priorities plugin.
    sudo ACCEPT_EULA=Y yum install msodbcsql-13.1.4.0-1 mssql-tools-14.0.3.0-1 unixODBC-devel –disableplugin=priorities –nogpgcheck

    I also ended up having to do the nogpgcheck because yum wouldn’t install the package (from your rhel6 repo) because – Package unixODBC-devel-2.3.1-4.el6.x86_64.rpm is not signed …

    I notice in the Ubuntu install we are copying your keys to apt-keys, but no equivalent step in RHEL. Is that intended?

    1. Meet Bhagdev says:

      We will get the devel package signed and put it up asap. You shouldn’t need to copy keys on RHEL/CentOS otherwise.

      1. Rob Olmos says:

        FYI I’m still getting the error “unixODBC-devel-2.3.1-4.el6.x86_64.rpm is not signed”

      2. Meet Bhagdev says:

        unixODBC devel is an optional package 🙂 Can you try these steps?
        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

  9. 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…”

  10. 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

  11. 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.

  12. 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?

      1. Chris says:

        I am running a 32-bit OS (Debian 8.8) on a 64-bit virtual machine. I am getting this same error, is it possible to use 32-bit? It ignores the microsoft package repo because it specifies 64-bit.

      2. Meet Bhagdev says:

        We only support 64-bit for the ODBC Driver.

  13. 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.

  14. 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.

  15. sm says:

    I get the same error

    1. Meet Bhagdev says:

      This should now be fixed!

  16. stavro says:

    i am getting the same error. repo is added.

    1. Meet Bhagdev says:

      This should now be fixed!

  17. 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

  18. 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