Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746

I'm using PHP Laravel 7.4 on Ubuntu 20.04.and trying to get data from SQL server located in windows server on another cloud.

this method was tested on my PC (Windows) and it successfully got the data from the windows server(mentioned above), But on my ubuntu server I follow the documents ubuntu 20.04 PHP 7.4 https://learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver15

I got this error:

SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746 (SQL: myquery) {"userId":94,"exception":"[object] (Illuminate\Database\QueryException(code: 08001): SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: Error code 0x2746 (SQL: myquery) at /var/www/web-api/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669)

I checked the logs in Microsoft SQL Server Management Studio and I notice this message appears every time I make a request from Ubuntu

"An TLS 1.2 connection request was received from a remote client application, but none of the cipher suites supported by the client application are supported by the server. The SSL connection request has failed."

like image 508
naif basalib Avatar asked Jul 20 '26 09:07

naif basalib


1 Answers

Try these steps:

  1. Install sqsrv & pdo_sqlsrv extension & restart apache

  2. Update & comment the mentioned line bellow in config/database.php sqlsrv array

    'port' => env('DB_PORT', '1433'),

Final value of sqlsrv driver will be like this:

'sqlsrv' => [
            'driver' => 'sqlsrv',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', 'localhost'),
            // 'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'prefix_indexes' => true,
        ],
  1. Hit these 2 command in command line of the project directory

      composer dump-autoload
    
      php artisan config:clear
    
like image 160
MD TAREK HOSSEN Avatar answered Jul 23 '26 00:07

MD TAREK HOSSEN