php - PDO异常 : Can't open lib 'ODBC Driver 13 for SQL Server'

标签 php sql-server macos laravel

我尝试从 macOS 连接 MSSQL。我的 PHP/Laravel 应用程序在 macOS 中运行。

基于此link ,我运行了以下两个命令:

# 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>

最佳答案

您需要使用 --no-sandbox 安装 ODBC,如 brew install --no-sandbox msodbcsql

https://github.com/Microsoft/homebrew-mssql-release/issues/1

关于php - PDO异常 : Can't open lib 'ODBC Driver 13 for SQL Server' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45474305/

相关文章:

mysql - 我如何让 datediff 在 sql 上与 min() max() 一起工作?

sql-server - SQL Server - varchar 值的转换溢出了 int 列

java - Maven 在构建时包括旧的 SNAPSHOT

xcode - mac 上缺少 OpenGL 头文件

php - 你如何在 MySQL 中订购 UNION?

php - 用于 php 的 eclipse : why syntax coloring go crazy?

php - 将 bash 换行符转换为 HTML 换行符;在 BASH 中运行良好,但不能通过 shell_exec

javascript - 推迟广告脚本执行

c++ - 即使我设置了限制,我的 for 语句也会不断重复?

sql - 在临时公用表表达式中添加自增列