I'm trying to connect Laravel 5.6 to my SQLEXPRESS.
When I try to migrate tables from Laravel to SQL, I am getting this error:
SQLSTATE[08001]: [Microsoft][ODBC Driver 13 for SQL Server]TCP
Provider: No connection could be made because the target machine actively refused it. (SQL: select * from sysobjects where type = 'U' and name = migrations)
I have installed the sqlsrv extionsion to php and tested it:
<?php
$serverName = "MYNAME\SQLEXPRESS";
$connectionInfo = array( "Database"=>"Portal", "UID"=>"sa", "PWD"=>"mySecretPwd");
$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));
}
?>
The connection is successfully established.
I also see the extension in the phpinfo();
But if switch to Laravel 5.6 with this settings:
my env:
DB_CONNECTION=sqlsrv
DB_HOST=MYNAME\SQLEXPRESS
DB_PORT=1433
DB_DATABASE=Portal
DB_USERNAME=sa
DB_PASSWORD=mySecredPwd
my config/database:
'default' => env('DB_CONNECTION', 'sqlsrv'),
'connections' => [
.....
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'MYNAME\SQLEXPRESS'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
],
],
I'm getting an error.
My serverconfigurations manager looks like this:
I can also connect with SQL Server Management Studio 2017.
See Question&Answers more detail:
os