Install Microsoft ODBC Driver 13 for SQL Server in Ubuntu 16.04
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
Related videos on Youtube
sss
Updated on June 04, 2022Comments
-
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 over 6 yearsI 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 over 6 yearsThanks 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 over 6 yearsWhen you run
odbcinst -j
do you seeDRIVERS............: /etc/odbcinst.ini
? And doespyodbc.drivers()
still return an empty list? -
sss over 6 yearsYes: 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 over 6 yearsAnd still the output of the pyodbc.drivers() is an empty array :(
-
Gord Thompson over 6 yearsand
/etc/odbcinst.ini
is not empty? -
sss over 6 yearsI checked /etc/odbcinst.ini is empty. Do u know what is the problem?
-
Gord Thompson over 6 yearsDoes
/usr/local/etc/odbcinst.ini
exist? If so, does it contain entries? -
sss over 6 yearsIt 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 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 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 over 6 yearsAs 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 over 6 yearsYes 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 over 6 yearsso the
/opt/microsoft/
folder exists but is completely empty? -
Boboyum over 6 yearsyou 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 over 6 years@GordThompson yes it exist but it empty
-
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 over 6 yearsThanks 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 over 5 yearsthx 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?