Which error are you getting? The one from the title or "could not find driver"?
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 top 1 * from [settings] where [name] = site_title and [settings].[deleted_at] is null)
I am just trying to migrate my laravel to sql server. I have installed Miscrosoft SQL Server. I have downloaded SQL server developer version and make default basic installation.
I am using wamp 64 with php 7.2.4. I have added two extensions in php.ini after I copied them inside wamp64/bin/php/php7.2.4/ext/
extension=php_pdo_sqlsrv_72_ts_x64 extension=php_sqlsrv_72_ts_x64
Now, I can see pdo_sqlsrv in phpinfo.
I have created a database in MSSQL and updated .env file as
DB_CONNECTION=sqlsrv
DB_HOST=DESKTOP-H9OGJE5\MSSQLSERVER
DB_PORT=1433
DB_DATABASE=kpi_db
DB_USERNAME=sa
DB_PASSWORD=
But, unfortunately I am getting this error when I tried to load. Also, I have tried to migrate through artisan command but with no success
Illuminate\Database\QueryException : could not find driver (SQL: select * from sysobjects where type = 'U' and name = migrations)
at C:\wamp64\www\project\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
> 664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|
Exception trace:
1 Doctrine\DBAL\Driver\PDOException::("could not find driver")
C:\wamp64\www\project\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:50
2 PDOException::("could not find driver")
C:\wamp64\www\project\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php:46
Please use the argument -v to see more details.
To resolve this problem, change the Server authentication from Windows Authentication mode to SQL Server.
To change the authentication mode to SQL Server and Windows, follow these steps:
- On the computer that is running Microsoft SQL Server, open SSMS.
- In the Server name box, type the name of the instance of SQL Server. For default, you can use dot(.) or (local)
- After connecting, in the Object Explorer window pane, right-click the SQL Instance and select Properties.
- Click Security under the select a page options.
- Change Server Authentication to SQL Server and Windows Authentication and click ok.
- Click ok to the prompt message about changes not taking effect until the instance is restarted.
- Right-click the SQL Instance in the Object Explorer and select Restart. Click Yes to restart the instance and if prompted to restart the SQL Server Agent.
After these changes have been applied and the SQL Instance has been restarted, attempt to verify the ODBC connection with the ‘sa’ account credentials.
Then try to connect through
<?php
$serverName = ".";
$connectionInfo = array( "Database"=>"kpi_db","UID"=>"sa", "PWD"=>"");
$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));
}
?>
If it successfully connected, remove port and fill other credentials.
Also, make sure you have copied extensions to ext folder and php.ini both in apache and php folder. As one is responsible for command and other is for the server. Let me know if any error arises.
Please or to participate in this conversation.