I just followed the setup to install php 7.1 drivers on my Mac but I'm having a few issues. I get two errors when I try to interact with the database.
[Illuminate\Database\QueryException]
SQLSTATE[01000]: [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13 for SQL Server' : file not found (SQL: select * from sysobjects where type = 'U' and name = migrations)
[PDOException]
SQLSTATE[01000]: [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13 for SQL Server' : file not found
Just found this and it fixed my issue.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install --no-sandbox msodbcsql mssql-tools
root@PARRAARANGO:~# sudo apt install msodbcsql mssql-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
N: Ignoring file 'libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
N: Ignoring file 'mssql-' in directory '/etc/apt/sources.list.d/' as it has no filename extension
E: Unable to locate package msodbcsql
E: Unable to locate package mssql-tools
root@PARRAARANGO:~# sudo apt-get update
Hit:1 http://deb.debian.org/debian stretch-updates InRelease
Ign:2 http://ftp.es.debian.org/debian/stretch-updates main InRelease
Ign:3 http://ftp.es.debian.org/debian/stretch-updates main Release
Ign:4 http://ftp.es.debian.org/debian/stretch-updates main/contrib Sources
Hit:5 https://packages.microsoft.com/debian/9/prod stretch InRelease
Ign:4 http://ftp.es.debian.org/debian/stretch-updates main/contrib Sources
Hit:6 https://packages.sury.org/php stretch InRelease
Ign:4 http://ftp.es.debian.org/debian/stretch-updates main/contrib Sources
Ign:7 http://ftp.us.debian.org/debian/stretch-updates main InRelease
Ign:8 http://ftp.us.debian.org/debian stretch InRelease
Ign:4 http://ftp.es.debian.org/debian/stretch-updates main/contrib Sources
Ign:9 http://ftp.us.debian.org/debian/stretch-updates main Release
Hit:10 http://ftp.us.debian.org/debian stretch Release
Ign:11 http://ftp.us.debian.org/debian/stretch-updates main/contrib Sources
Ign:4 http://ftp.es.debian.org/debian/stretch-updates main/contrib Sources
Ign:11 http://ftp.us.debian.org/debian/stretch-updates main/contrib Sources
Ign:11 http://ftp.us.debian.org/debian/stretch-updates main/contrib Sources
Err:4 http://ftp.es.debian.org/debian/stretch-updates main/contrib Sources
404 Not Found
Ign:11 http://ftp.us.debian.org/debian/stretch-updates main/contrib Sources
Ign:11 http://ftp.us.debian.org/debian/stretch-updates main/contrib Sources
Err:11 http://ftp.us.debian.org/debian/stretch-updates main/contrib Sources
404 Not Found [IP: 128.61.240.89 80]
Reading package lists... Done
N: Ignoring file 'libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
N: Ignoring file 'mssql-' in directory '/etc/apt/sources.list.d/' as it has no filename extension
W: The repository 'http://ftp.es.debian.org/debian/stretch-updates main Release' does not have a Release file.
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.
W: The repository 'http://ftp.us.debian.org/debian/stretch-updates main Release' does not have a Release file.
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.
E: Failed to fetch http://ftp.es.debian.org/debian/stretch-updates/dists/main/contrib/source/Sources 404 Not Found
E: Failed to fetch http://ftp.us.debian.org/debian/stretch-updates/dists/main/contrib/source/Sources 404 Not Found [IP: 128.61.240.89 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
root@PARRAARANGO:~# sudo apt-get install msodbcsql
Reading package lists... Done
Building dependency tree
Reading state information... Done
N: Ignoring file 'libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
N: Ignoring file 'mssql-' in directory '/etc/apt/sources.list.d/' as it has no filename extension
E: Unable to locate package msodbcsql
root@PARRAARANGO:~# sudo apt-get install unixodbc-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
unixodbc-dev is already the newest version (2.3.4-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
N: Ignoring file 'libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
N: Ignoring file 'mssql-' in directory '/etc/apt/sources.list.d/' as it has no filename extension
Reading package lists... Done
Building dependency tree
Reading state information... Done
N: Ignoring file 'libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
N: Ignoring file 'mssql-' in directory '/etc/apt/sources.list.d/' as it has no filename extension
E: Unable to locate package msodbcsql
Oddly, I'm seeing this error whenever I try to run sqlsrv_connect even though I've followed all the instructions carefully for installing ODBC 17 (because I'm on Debian 9). I can use sqlcmd just fine to talk to the DB, but not PHP. I do notice that I have both PHP 7.1 and PHP 7.2 installed. Could the fact that I have two installs be fouling up something in the ODBC 17 installation process? Thanks.
@elramus sqlcmd is part of mssql-tools, not the ODBC driver. Just to clarify, I assume you are using the msodbcsql and mssql-tools previews available on this page? Also, PHP installs have nothing to do with the ODBC driver install, so that is not the problem.
If the error you are getting says that ODBC driver 13 cannot be found, you can add the Driver keyword to the connection string and specify version 17 as follows:
Driver={ODBC Driver 17 for SQL Server};
or in the connection options in your PHP script,
array("Driver"=>"ODBC Driver 17 for SQL Server");
Please let us know if this fixes the problem.
@mauricio0015 Please follow the instructions on the ODBC install page to install msodbcsql and mssql-tools. If you are using Debian 9 or Ubuntu 17.10, you may need to use the preview versions on this page instead, because their public repositories have not been updated.
In my case on openSUSE I get the following error:
Message: [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13 for SQL Server' : file not found
I don't know why is trying to use Driver 13. I am testing on PHP 7.2.1
Thanks for the clarifications @david-puglielli. Yes, I got msodbcsql and mssql-tools through the instructions here. For some context, my end goal is to have Laravel framework in a LAMP environment talk to an MS SQL Server database. Found lots of conflicting info on how to get Laravel to talk to MS SQL, so I'm unclear on which PHP driver(s) I need: sqlsrv, pdo_sqlsrv, pdo_odbc, or pdo_dblib.
I tried adding "Driver"=>"ODBC Driver 17 for SQL Server" to the connection options of sqlsrv_connect, but it shows SQLSTATE: IMSSP<br/>Code: -1<br/>Message: Invalid option Driver was passed to sqlsrv_connect.
@elramus I think you may be using the stable version of the sqlsrv driver, which does not support ODBC driver 17. Could you try pecl install sqlsrv-5.2.0RC1 (or download the latest binaries from the releases page) and let us know if the problem is fixed? Thanks!
hi @david-puglielli, I stopped trying with Deb 9 to avoid dealing with ODBC 17 altogether. Tried a bunch of times with Ubuntu 16.04, but still ran into basically the same thing. Opened a new issue: https://github.com/Microsoft/msphpsql/issues/689. Thanks for your help with this.
@david-puglielli Thanks. Changing the driver name worked.
I was infact trying to access sql data warehouse azure via python notebook in the ML studio. The driver not found error was out puting. The issue is posted on SO as well.
Thanks.
Closing this issue due to inactivity. If any of you still have issues, please create a new issue. Thank you.
Still encountering some issues. Having installed pyodbc with conda, and msodbcsql as per https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server I encounter the same error.
Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13 for SQL Server' : file not found (0) (SQLDriverConnect)")
DId you install ODBC 17 or ODBC 13, @willgdjones ? Which platform?
Assuming you're looking for ODBC 13, please type odbcinst -q -d -n "ODBC Driver 13 for SQL Server" and see if the driver really exists in the path. For example, in CentOS, you may see something like
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9.2
UsageCount=1
Check if /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9.2 actually exists.
This is on Mac OSX 10.3.1
Data KUL git:(master) ✗ odbcinst -q -d -n "ODBC Driver 13 for SQL Server"
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/usr/local/lib/libmsodbcsql.13.dylib
UsageCount=1
It seems that the driver is installed on my system.
hi @willgdjones , regrettably we don't support anything lower than Mac OS X 10.11
Even if it looks like ODBC 13 is installed, it may not work properly.
Help im trying to connect from cpanel webhost to sql hosted in windows server, but having this problem SQLSTATE [01000] SQLDriverConnect: 0 [unixODBC] [Driver Manager] Can not open lib 'SQL Server': file not found
Please help
@Dkeimerunthe You need to have the ODBC driver installed. Here is the link.
Thanks david-puglielli, i am sorry im not good at this, but i already installed the Microsoft ODBC Driver 17 for sql server in my machine. but still encountering the same problem check my web olympusmuonline.com
it says the error
You guys might not have ODBC drive. Please install it first.
sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
-Download appropriate package for the OS version
-Choose only ONE of the following, corresponding to your OS version
Ubuntu 14.04
curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
Ubuntu 16.04
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
Ubuntu 17.10
curl https://packages.microsoft.com/config/ubuntu/17.10/prod.list > /etc/apt/sources.list.d/mssql-release.list
Ubuntu 18.04
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17
optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
optional: for unixODBC development headers
sudo apt-get install unixodbc-dev
Most helpful comment
You guys might not have ODBC drive. Please install it first.
sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
-Download appropriate package for the OS version
-Choose only ONE of the following, corresponding to your OS version
Ubuntu 14.04
curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list > /etc/apt/sources.list.d/mssql-release.listUbuntu 16.04
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.listUbuntu 17.10
curl https://packages.microsoft.com/config/ubuntu/17.10/prod.list > /etc/apt/sources.list.d/mssql-release.listUbuntu 18.04
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.listoptional: for bcp and sqlcmd
optional: for unixODBC development headers
sudo apt-get install unixodbc-dev