我无法将 Joomla 连接到 MSSQL
我不断得到
Could not connect to the database. Connector returned number: Database sqlsrv_connect failed
我使用的是 MySQLi 驱动程序还是我安装的驱动程序 (Microsoft SQL Server)
似乎是驱动安装问题,
我可以使用 Mssql 客户端连接到同一个盒子...
有人可以解释一下如何从头开始在 PHP 上为 Joomla 安装 MSSQL 驱动程序吗?
或者发送有关如何执行此操作的最新引用资料?
Joomla 3.4
PHP 5.6
IIS 7.5
MSSQL 2008 R2
如果我将驱动程序切换为:php_sqlsrv_54_ts.dll - 它将从 joomla 安装程序中的“数据库类型”中分散..
谢谢
最佳答案
显示的 joomla 错误具有误导性且不是很有用。
所以第一步是修改 joomla 代码以找出确切的错误。
在应用程序的根目录中修改 connect() 函数中的以下代码
库\joomla\数据库\驱动程序\sqlsrv.php
来自
// Attempt to connect to the server.
if (!($this->connection = @ sqlsrv_connect($this->options['host'], $config)))
{
throw new RuntimeException('Database sqlsrv_connect failed');
}
到
// Attempt to connect to the server.
if (!($this->connection = @ sqlsrv_connect($this->options['host'], $config)))
{
throw new RuntimeException("Database sqlsrv_connect failed - Error : ".print_r( sqlsrv_errors(), true));
}
这将为您提供确切的错误信息,并指导您完成所需的后续步骤。
安装 SQL Server 时要考虑的另一件事是启用 SQL Server 身份验证,因为 Joomla 默认使用 SQL Server 身份验证。
您可以通过 checkin 上述同一文件中的相同函数来确认 Joomla 使用 SQL Server 身份验证
$config = array(
'Database' => $this->options['database'],
'uid' => $this->options['user'],
'pwd' => $this->options['password'],
'CharacterSet' => 'UTF-8',
'ReturnDatesAsStrings' => true);
这是确认相同的 PHP 手册。 http://php.net/manual/en/function.sqlsrv-connect.php
您可以在安装期间或安装后从管理工作室启用 SQL 服务器身份验证。
希望这对您有所帮助。
关于php - 无法连接到数据库。连接器返回编号 : Database sqlsrv_connect failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29639044/