我正在尝试使用 sqlsrv_connect 连接到外部 SQLServer。 在我的 php_info() 页面中我看到:
PDO -> PDO drivers -> mysql, odbc, sqlsrv
PDO_ODBC -> ODBC Connection Pooling -> Enabled, strict matching
pdo_sqlsrv -> pdo_sqlsrv support -> support ExtensionVer 5.11.1
这是我的PHP代码
$serverName = "tcp:123.123.123.123,1443";
$connectionInfo = array("Uid" => 'login', "PWD" => 'password', "LoginTimeout" => 10);
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn === false) var_dump(sqlsrv_errors());
返回的错误是
This extension requires the Microsoft ODBC Driver for SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712
所以我尝试使用 MS 指令安装 ODBC 安装适用于 SQL Server (Linux) 的 Microsoft ODBC 驱动程序页面
当我这样做时
apt-get update
返回
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://deb.debian.org/debian bookworm-updates InRelease
Hit:3 http://security.debian.org/debian-security bookworm-security InRelease
Hit:4 https://packages.sury.org/php bookworm InRelease
Get:5 https://packages.microsoft.com/debian/12/prod bookworm InRelease [3617 B]
Err:5 https://packages.microsoft.com/debian/12/prod bookworm InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
Reading package lists... Done
W: GPG error: https://packages.microsoft.com/debian/12/prod bookworm InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
E: The repository 'https://packages.microsoft.com/debian/12/prod bookworm InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
所以我已经尝试过
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EB3E94ADBE1229CF
但是
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
Executing: /tmp/apt-key-gpghome.5QMg7Qrr5w/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys EB3E94ADBE1229CF
gpg: key EB3E94ADBE1229CF: "Microsoft (Release signing) <[email protected]>" not changed
gpg: Total number processed: 1
gpg: unchanged: 1
当我这样做时
apt-get update
容易返回相同的错误。
有什么想法吗?
已由 Microsoft 解决,位于 此页面