Install Microsoft ODBC Driver 13 for SQL Server in Ubuntu 16.04

13,608

There are up to date instructions on how to set up SQLServer and ODBC on Ubuntu for Python Development at https://www.microsoft.com/en-us/sql-server/developer-get-started/python/ubuntu/

This is maintained by the SQL Server Product team.

The latest instructions for installing ODBC can be found at https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server#microsoft-odbc-driver-131-for-sql-server

Share:
13,608

Related videos on Youtube

sss
Author by

sss

Updated on June 04, 2022

Comments

  • sss
    sss almost 2 years

    I am trying to install ODBC Driver 13 on Ubuntu 16.04 but after installation still, the driver is missing. I followed the steps from this page, but when I want to connect, the driver still missing.

    Below code is also return empty array:

    import pyodbc
    print(pyodbc.drivers())
    

    Furthermore when I want to install via:

    wget https://gallery.technet.microsoft.com/ODBC-Driver-13-for-Ubuntu-b87369f0/file/154097/2/installodbc.sh
    

    inside of the installodbc.sh the part below gives me an error which cannot find the ./install.sh:

    echo "Installing the Microsoft ODBC Driver 13 for SQL Server- Ubuntu"
    sudo bash ./install.sh install --force --accept-license
    echo "Cleaning up"
    rm -rf /tmp/msodbcubuntu
    

    Does anyone know how to fix this issue? I tried all the possible answers on the internet still the driver is missing and I can't establish the connection.

    • Gord Thompson
      Gord Thompson over 6 years
      I have installed the 13.1 version of the driver on Ubuntu 16.04 many times using the instructions here and it has worked fine for me every time. The shell script you cited is quite old and should no longer be used. I'd suggest that you retry each of the steps for 16.04 on the Microsoft Docs page, keeping an eye out for any error messages that may appear.
    • sss
      sss over 6 years
      Thanks for the answer @GordThompson I followed the steps to install the 13.1 version for Ubuntu 16.04. However when I want to connect to the server in python I get this error still: "Error ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13.1 for SQL Server' : file not found (0) (SQLDriverConnect) ")"
    • Gord Thompson
      Gord Thompson over 6 years
      When you run odbcinst -j do you see DRIVERS............: /etc/odbcinst.ini? And does pyodbc.drivers() still return an empty list?
    • sss
      sss over 6 years
      Yes: This is the output of the odbcinst -j : unixODBC 2.3.4 DRIVERS............: /etc/odbcinst.ini SYSTEM DATA SOURCES: /etc/odbc.ini FILE DATA SOURCES..: /etc/ODBCDataSources USER DATA SOURCES..: /home/samin/.odbc.ini SQLULEN Size.......: 8 SQLLEN Size........: 8 SQLSETPOSIROW Size.: 8
    • sss
      sss over 6 years
      And still the output of the pyodbc.drivers() is an empty array :(
    • Gord Thompson
      Gord Thompson over 6 years
      and /etc/odbcinst.ini is not empty?
    • sss
      sss over 6 years
      I checked /etc/odbcinst.ini is empty. Do u know what is the problem?
    • Gord Thompson
      Gord Thompson over 6 years
      Does /usr/local/etc/odbcinst.ini exist? If so, does it contain entries?
    • sss
      sss over 6 years
      It exist and contain [ODBC Driver 13 for SQL Server] Description=Microsoft ODBC Driver 13 for SQL Server Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9‌​.0 UsageCount=1 as entry.
    • Gord Thompson
      Gord Thompson over 6 years
      cd /etc && sudo ln -s -f /usr/local/etc/odbcinst.ini should replace the empty file in /etc/ with a link to the correct file in /usr/local/etc/.
    • sss
      sss over 6 years
      @GordThompson thank you very much. Now I get the driver. But the SYSTEM DATA Source /etc/odbc.ini is also empty idk if that is the problem but I still cannot accomplish the connection it still says Error ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13.1 for SQL Server' : file not found (0) (SQLDriverConnect) ")
    • Gord Thompson
      Gord Thompson over 6 years
      As per your comment above, the driver entry is [ODBC Driver 13 for SQL Server] so the driver name is "ODBC Driver 13 for SQL Server", not "ODBC Driver 13.1 for SQL Server".
    • sss
      sss over 6 years
      Yes I put the name of the driver [ODBC Driver 13 for SQL Server] but in the odbcinst.ini is looking for the Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9‌​‌​.0 which there is nothing in microsoft folder
    • Gord Thompson
      Gord Thompson over 6 years
      so the /opt/microsoft/ folder exists but is completely empty?
    • Boboyum
      Boboyum over 6 years
      you shouldnt have to run that technet script. it is out of date. The latest instructions for installing ODBC can be found at docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/…
    • sss
      sss over 6 years
      @GordThompson yes it exist but it empty
    • sss
      sss over 6 years
      @GordThompson Thank you so much with all the help. I finally fix it. /opt/microsoft/msodbcsql/lib64/libmsodbcsql-* was missing but I found the installation package in /var/cache/apt/archives/msodbcsql_13.1.9.0-1_amd64.deb and install it at /opt/microsoft/msodbcsql and now everything is there and working.
  • sss
    sss over 6 years
    Thanks for the answer as @GordThompson also said I tried it things go well without any error but when I want to connect this file does not exist -> ./opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9‌​‌​.0‌​. for more info I am using pyodbc 4.0.17 and python 3.6.2.
  • dcparham
    dcparham over 5 years
    thx for that. that path and file exist, so why does my Ubuntu 16.04, PHP7.0 not use sql to understand mssql? is PHP7.0 really simply not going to understand mssql, regardless of providing ODBC?