我正在尝试连接到我的sql server数据库,但我不断收到此消息:
Array ( [0] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456
[code] => 18456 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'NT AUTHORITY\SYSTEM'. [message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'NT AUTHORITY\SYSTEM'. )
[1] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 4060
[code] => 4060[2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot open database "Store" requested by the login. The login failed.
[message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot open database "Store" requested by the login. The login failed. )
[2] => Array ( [0] => 28000 [SQLSTATE] => 28000 [1] => 18456 [code] => 18456 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'NT AUTHORITY\SYSTEM'.
[message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Login failed for user 'NT AUTHORITY\SYSTEM'. )
[3] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 4060
[code] => 4060 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot open database "Store" requested by the login. The login failed.
[message] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Cannot open database "Store" requested by the login. The login failed. ) )
我甚至不明白NT AUTHORITY \ SYSTEM用户是什么。 它在Apache上运行。
UPD:忘记添加代码
<?php
$servername="(local)";
$connection=array("Database"=>"Store");
$link = sqlsrv_connect($servername,$connection);
if( $link )
{
echo "Connection established.\n";
}
else
{
echo "Connection could not be established.\n";
die( print_r( sqlsrv_errors(), true));
}
?>
UPD2: 问题解决了。一如既往,我试图使用一些帮助。 感谢您解释NT Authority \ System用户的内容。 将运行apache的用户更改为用于sqlserver的用户,它可以正常工作。
答案 0 :(得分:0)
看看这是否已解决:http://security.fnal.gov/cookbook/LocalSystem.html
检查DB Store是否也存在!
祝你好运!