Skip to content

Instantly share code, notes, and snippets.

@Raza9798
Created July 15, 2024 17:12
Show Gist options
  • Save Raza9798/3b66c3abb22c8380ef64e6a91e37d5eb to your computer and use it in GitHub Desktop.
Save Raza9798/3b66c3abb22c8380ef64e6a91e37d5eb to your computer and use it in GitHub Desktop.
Laravel SQLsrv connection examable
'local_sqlsrv' => [
'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => '192.168.2.50', // IP ADDRESS OF YOUR MACHINE
'port' => '1433', // PORT
'database' => 'inteldemo', // DATABASE
'username' => 'intel', // user name on MSSQL SERVER
'password' => 'demolaravel', // password on MSSQL SERVER
'prefix' => '',
'charset' => 'utf8',
'collation' => 'utf8mb4_unicode_ci',
'prefix_indexes' => true,
'strict' => false,
'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'true'),
],
Enable TCP/IP for SQL Server in order to connect MSSQL SERVER TO LARAVEL APPLICATION
-> Open SQL Server Configuration Manager
-> naviage to SQL Server network configuration
-> enable TCP/IP protocol
-> doubel click to open the properties and navigate to IP Address tab and goto IPALL section and fill TCP PORT as 1433
-> Goto SQL Server Serives in the Sql server configuration manager and restare the SQL Server (SQLEXPRESS) service
above method will resolve the issue that i faced on laravel. [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: No connection could be made because the target machine actively refused it.
following is the database connection example to config the second database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment