[英]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.我在 Ubuntu 20.04 上使用 PHP Laravel 7.4。并尝试从位于另一个云上的 Windows 服务器中的 SQL 服务器获取数据。
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://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver15此方法在我的 PC (Windows) 上进行了测试,它成功地从 Windows 服务器(上面提到)获取了数据,但是在我的 ubuntu 服务器上,我遵循文档 ubuntu 20.04 PHP 7.4 https://docs.microsoft.com/en-我们/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)
SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]TCP 提供程序: 错误代码 0x2746 (SQL: myquery) {"userId":94,"exception":"[object] (Illuminate\Database\QueryException(code : 08001): SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]TCP 提供程序: /var/www/web-api/vendor/laravel/framework/src/Illuminate 处的错误代码 0x2746 (SQL: myquery) /数据库/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我检查了 Microsoft SQL Server Management Studio 中的日志,发现每次从 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."
“从远程客户端应用程序收到 TLS 1.2 连接请求,但服务器不支持客户端应用程序支持的密码套件。SSL 连接请求失败。”
I think I have faced similar error when using mssql with laravel.我想我在使用带有 laravel 的 mssql 时遇到了类似的错误。 I solved it by installing and enabling the mssql php extension on the machine.
我通过在机器上安装和启用 mssql php 扩展解决了这个问题。 Maybe it will help.
也许会有所帮助。
使用 docker 和thecodingmachine/php
8.0,我通过使用https://github.com/microsoft/msphpsql/issues/1023#issuecomment-732947905中的配置编辑/etc/ssl/openssl.cnf
解决了这个问题
Try these steps:尝试以下步骤:
Install sqsrv & sqlsrv_pdo extension restart apache安装 sqsrv & sqlsrv_pdo 扩展重启 apache
Update & comment the mentioned line bellow in config/database.php sqlsrv array在 config/database.php sqlsrv 数组中更新并评论下面提到的行
'port' => env('DB_PORT', '1433'), 'port' => env('DB_PORT', '1433'),
Final value of sqlsrv driver will be like this: sqlsrv 驱动程序的最终值将如下所示:
'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,
],
Hit these 2 command in command line of the project directory在项目目录的命令行中点击这两个命令
composer dump-autoload php artisan config:clear
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.