2013-05-27 76 views
2

我試圖連接到我的SQL Server數據庫,但我不斷收到這樣的信息:將php連接到MS 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的工作。

+2

NT Authority \ System是什麼運行Apache。它的Windows系統帳戶。 –

+0

您使用的連接數據庫的證書存在問題 - 請問您可以將該代碼添加到您的問題中嗎?無論如何,一旦你刪除了所有實際的登錄信息。 – andrewsi

回答