msphpsql: Can't open lib 'ODBC Driver 13 for SQL Server
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
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 22 (7 by maintainers)
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.10curl 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-devJust found this and it fixed my issue.
https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
@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:
or in the connection options in your PHP script,
Please let us know if this fixes the problem.
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.
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