我尝试从macOS连接MSSQL。我的PHP / Laravel应用程序在macOS中运行。
基于此here,我运行了以下两个命令:
# sudo pecl install sqlsrv
# sudo pecl install pdo_sqlsrv
我收到消息说已经安装了。
pecl/pdo_sqlsrv is already installed and is the same as the released version 4.3.0
install failed.
但是当我尝试连接mssql时,
#php artisan migrate:install
我得到以下异常:
Illuminate\Database\QueryException]
SQLSTATE[01000]: [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13 for SQL Server' : file not found (SQL: create table "migrat
ions" ("id" int identity primary key not null, "migration" nvarchar(191) not null, "batch" int not null))
[PDOException]
SQLSTATE[01000]: [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13 for SQL Server' : file not found
我还需要安装什么?我的php版本是7.1
我尝试时遇到的问题
# brew install msodbcsql
Error: Formulae found in multiple taps:
* microsoft/msodbcsql/msodbcsql
* microsoft/mssql-preview/msodbcsql
Please use the fully-qualified name e.g. `microsoft/msodbcsql/msodbcsql` to refer the formula.
所以改为:
# brew install microsoft/msodbcsql/msodbcsql
然后我得到了这个;
Do you accept the license terms? (Enter YES or NO)
YES
==> odbcinst -u -d -n "ODBC Driver 13 for SQL Server"
==> odbcinst -i -d -f ./odbcinst.ini
Last 15 lines from /Users/ratha/Library/Logs/Homebrew/msodbcsql/02.odbcinst.ini:
2017-08-03 14:03:06 +1000
odbcinst -i -d -f ./odbcinst.ini
odbcinst: SQLInstallDriverEx failed with Invalid install path.
If reporting this issue please do so to (not Homebrew/brew or Homebrew/core):
microsoft/msodbcsql
/usr/local/Homebrew/Library/Homebrew/utils/github.rb:226:in `raise_api_error': curl failed! (GitHub::Error)
curl: (22) The requested URL returned error: 422 Unprocessable Entity
curl: (3) <url> malformed
from /usr/local/Homebrew/Library/Homebrew/utils/github.rb:184:in `open'
from /usr/local/Homebrew/Library/Homebrew/utils/github.rb:233:in `issues_matching'
from /usr/local/Homebrew/Library/Homebrew/utils/github.rb:272:in `issues_for_formula'
from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:369:in `fetch_issues'
from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:365:in `issues'
from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:419:in `dump'
from /usr/local/Homebrew/Library/Homebrew/brew.rb:133:in `rescue in <main>'
from /usr/local/Homebrew/Library/Homebrew/brew.rb:26:in `<main>
答案 0 :(得分:3)
您需要使用NSArray<BRAWorksheet *> *
作为--no-sandbox
https://github.com/Microsoft/homebrew-mssql-release/issues/1
答案 1 :(得分:1)
我相信Mac上尚未安装“Microsoft ODBC Driver 13”的先决条件。
根据这篇blog帖子,微软似乎正在开发Mac版本的驱动程序。
因为你正在与Laravel合作;先试试;
composer update && upgrade
从Web应用程序的根目录中查看它是否可以自动提取所有依赖项。
如果没有尝试按照上面提供的链接中的说明安装驱动程序。
如果您已经安装了ODBC驱动程序,它应该位于Mac上的以下目录中;
/Library/ODBC/
干杯。
答案 2 :(得分:1)
重新安装软件包:
brew tap microsoft/msodbcsql https://github.com/Microsoft/homebrew-mssql-release
ACCEPT_EULA=y brew reinstall --no-sandbox msodbcsql mssql-tools
如果仍在发生,请运行:
cp -v "$(brew list msodbcsql | grep odbcinst.ini$)" ~/.odbcinst.ini
复制定义SQL ODBC驱动程序位置的INI文件。
或手动创建文件,例如
printf "[ODBC Driver 13 for SQL Server]\nDescription=Microsoft ODBC Driver 13 for SQL Server\nDriver=/usr/local/lib/libmsodbcsql.13.dylib\n" >> ~/.odbcinst.ini
错误报告:SQL Server : Can't open lib 'ODBC Driver 13 for SQL Server'。
请参阅:Installing the Microsoft ODBC Driver for SQL Server on Linux and macOS。
如果您使用的是Anaconda,请查看此问题:ODBC Driver 13 for SQL Server can't open lib。