使用SQL Server 2017进行Wampserver配置

时间:2018-03-21 06:31:49

标签: php sql-server wamp wampserver

欢迎阅读此内容的任何人。使用Wampserver&amp ;;我遇到了严重的配置问题。 SQL Server 2017.PHP版本是7.1.9。 Apache 2.4.27。我收到的灵感来自几年前制作的视频https://www.youtube.com/watch?v=AUUh_WVzqq4。我此时想要做的就是在本地设置与数据库的连接。我发布了我的PHP代码,这是我输出到浏览器的错误...

Connection could not be established.
Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'WORKGROUP\DESKTOP-REPGNI2$'. [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'WORKGROUP\DESKTOP-REPGNI2$'. ) [1] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 4060 [code] => 4060 [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot open database "officialdatabase" requested by the login. The login failed. [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot open database "officialdatabase" requested by the login. The login failed. ) [2] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'WORKGROUP\DESKTOP-REPGNI2$'. [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'WORKGROUP\DESKTOP-REPGNI2$'. ) [3] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 4060 [code] => 4060 [2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot open database "officialdatabase" requested by the login. The login failed. [message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Cannot open database "officialdatabase" requested by the login. The login failed. ) )

基于我一直在查找的内容,这似乎是一个常见的错误。我已尝试将我的驱动程序更新到最新版本 ODBC驱动程序13 for SQL Server TO ODBC驱动程序17 for SQL Server 。我在Apache中的php.ini中有dll文件(我认为),并且作为证据看到phpinfo()screenshot。这些dll文件顺便提供了适用于PHP的7.0+版本的文件。该服务以名称" NT Service \ MSSQLSERVER"运行。我已经尝试将此更改为我的数据库中的真实用户,这只是我在Windows身份验证下(在SQL Server中我的Windows身份验证还具有数据库的权限)。我也试过填写" UID"和" PWD"我的connectionInfo中的字段与我作为管理员创建的用户。我尝试重新下载Microsoft Visual C ++ 2013 Redistributable(x64) - 12.0.30501。所有这些都导致没有成功和相同的错误。知道问题可能是什么?

<?php
$serverName = "Desktop-repgni2"; //serverName\instanceName

// Since UID and PWD are not specified in the $connectionInfo array,
// The connection will be attempted using Windows Authentication.
$connectionInfo = array( "Database"=>"officialdatabase");
$conn = sqlsrv_connect($serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>

0 个答案:

没有答案