无法连接到数据库。连接器返回编号:数据库 sqlsrv_connect 失败
Could not connect to the database. Connector returned number: Database sqlsrv_connect failed
我无法将 Joomla 连接到 MSSQL
我不断收到
Could not connect to the database. Connector returned number: Database
sqlsrv_connect failed
我使用的是MySQLi驱动还是我安装的驱动(微软SQL服务器)
似乎是驱动安装问题,
我可以使用 Mssql 客户端连接到同一个盒子...
有人可以 post 解释如何从头开始在 PHP 上为 Joomla 安装 MSSQL 驱动程序吗?
或者发送有关如何执行此操作的最新参考资料?
Joomla 3.4
PHP 5.6
IIS 7.5
MSSQL 2008 R2
如果我将驱动程序切换为:php_sqlsrv_54_ts.dll - 它会从 joomla 安装程序中的 "database type" 分散..
谢谢
- 下载 SQLServer 2008 Express、SQLServer 2008 Standard/Enterprise
版本(R2 或更高版本)
- 下载 PHP 驱动程序
- 下载SQLSRV20.EXE到临时目录
- 运行 SQLSRV20.EXE
- 出现提示时,输入 PHP 扩展目录的路径
- 如果您正在使用某种 LAMP 堆栈,例如 XAMPP
- 将php_sqlsrv_52_ts_vc6.dll复制到php/ext文件夹
在php.ini中输入如下
- 分机=php_sqlsrv_52_ts_vc6.dll
注:
- 如果您需要 PDO 或 vc9 版本 - 请复制 "ts" 版本
适合您的需求。
- 如果您使用的 IIS 带有通过 FAST-CGI 安装的 PHP 引擎 - 请
在 c:\Program Files\php\php.ini 和
将 dll 复制到 c:\Program Files\php\ext 文件夹
现在 - 您可以通过在安装步骤 4 的下拉列表中选择 SQLServer 2008 来安装 Joomla 2.5。
安装完成后 - 继续导航 administrator/site
显示的 joomla 错误具有误导性且不是很有用。
所以第一步是修改 joomla 代码以找出确切的错误。
在应用程序的根目录
中修改connect()函数中的以下代码
libraries\joomla\database\driver\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 服务器安装期间要考虑的另一件事是启用 SQL 服务器身份验证,因为 Joomla 默认使用 SQL 服务器身份验证。
您可以确认 Joomla 使用 SQL 服务器身份验证,方法是检查上述同一文件中的相同功能
$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 服务器身份验证,也可以从管理工作室 post 安装。
希望对您有所帮助。
我无法将 Joomla 连接到 MSSQL
我不断收到
Could not connect to the database. Connector returned number: Database sqlsrv_connect failed
我使用的是MySQLi驱动还是我安装的驱动(微软SQL服务器)
似乎是驱动安装问题,
我可以使用 Mssql 客户端连接到同一个盒子...
有人可以 post 解释如何从头开始在 PHP 上为 Joomla 安装 MSSQL 驱动程序吗?
或者发送有关如何执行此操作的最新参考资料?
Joomla 3.4
PHP 5.6
IIS 7.5
MSSQL 2008 R2
如果我将驱动程序切换为:php_sqlsrv_54_ts.dll - 它会从 joomla 安装程序中的 "database type" 分散..
谢谢
- 下载 SQLServer 2008 Express、SQLServer 2008 Standard/Enterprise 版本(R2 或更高版本)
- 下载 PHP 驱动程序
- 下载SQLSRV20.EXE到临时目录
- 运行 SQLSRV20.EXE
- 出现提示时,输入 PHP 扩展目录的路径
- 如果您正在使用某种 LAMP 堆栈,例如 XAMPP
- 将php_sqlsrv_52_ts_vc6.dll复制到php/ext文件夹
在php.ini中输入如下
- 分机=php_sqlsrv_52_ts_vc6.dll
注:
- 如果您需要 PDO 或 vc9 版本 - 请复制 "ts" 版本 适合您的需求。
- 如果您使用的 IIS 带有通过 FAST-CGI 安装的 PHP 引擎 - 请 在 c:\Program Files\php\php.ini 和 将 dll 复制到 c:\Program Files\php\ext 文件夹
现在 - 您可以通过在安装步骤 4 的下拉列表中选择 SQLServer 2008 来安装 Joomla 2.5。
安装完成后 - 继续导航 administrator/site
显示的 joomla 错误具有误导性且不是很有用。
所以第一步是修改 joomla 代码以找出确切的错误。
在应用程序的根目录
libraries\joomla\database\driver\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 服务器安装期间要考虑的另一件事是启用 SQL 服务器身份验证,因为 Joomla 默认使用 SQL 服务器身份验证。
您可以确认 Joomla 使用 SQL 服务器身份验证,方法是检查上述同一文件中的相同功能
$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 服务器身份验证,也可以从管理工作室 post 安装。
希望对您有所帮助。