Estou tentando conectar em um banco SQL Server utilizando PHP, mas a operação está dando timed out.
Utilizando o SSMS (Management Studio) com as mesmas informações da string do PHP, é possível conectar normalmente no banco.
PHP:
$serverName = "servidor"; $connectionInfo = array("Database" => "database", "UID" => "usuario", "PWD" => "senha"); $conn = sqlsrv_connect($serverName, $connectionInfo); if (!$conn) die( print_r( sqlsrv_errors(), true));
Erro:
Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 258 [code] => 258 [2] => [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: The wait operation timed out. [message] => [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: The wait operation timed out. ) [1] => Array ( [0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired [message] => [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 258 [code] => 258 [2] => [Microsoft][ODBC Driver 17 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. [message] => [Microsoft][ODBC Driver 17 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. ) )
Estou utilizando o PHP 7.2.7
e Microsoft Driver 5.3 para PHP 7.2
, e tudo está sendo rodado em IIS.
O erro seria por conta da versão do driver ou da versão do php? Ou pode ser algo nada relacionado à isso?
$serverName
? E a porta?