简体   繁体   English

SQLSTATE[08001]:[Microsoft][ODBC Driver 17 for SQL Server]TCP 提供程序:错误代码 0x2746

[英]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:尝试以下步骤:

  1. Install sqsrv & sqlsrv_pdo extension restart apache安装 sqsrv & sqlsrv_pdo 扩展重启 apache

  2. 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,
        ],
  1. 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.

相关问题 错误:SQLSTATE[08001]:[Microsoft][ODBC Driver 17 for SQL Server]客户端不支持加密 - Error:SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]Encryption not supported on the client SQLSTATE[08001]:[Microsoft][ODBC Driver 13 for SQL Server]TCP Provider:无法建立连接,因为目标机器主动拒绝它 - SQLSTATE[08001]: [Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: No connection could be made because the target machine actively refused it SQLSTATE 08001 [Microsoft][SQL 服务器的 ODBC 驱动程序 18]SSL 提供程序:证书链是由不受信任的机构颁发的 - SQLSTATE 08001 [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: The certificate chain was issued by an authority that is not trusted 42000 [SQLSTATE] [Microsoft] [用于 SQL 服务器的 ODBC 17 驱动程序] [SQL Server] 无法打开数据库“ - 42000 [SQLSTATE] [Microsoft] [ODBC 17 driver for SQL Server] [SQL Server] It is not possible to open the database " PDOException: SQLSTATE[HYT00]: [Microsoft][ODBC Driver 17 for SQL 服务器]登录超时在 Centos 7 上过期 - PDOException: SQLSTATE[HYT00]: [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired on Centos 7 SQLSTATE [HY000]:[Microsoft] [SQL Server的ODBC驱动程序11] TDS协议错误 - SQLSTATE[HY000]: [Microsoft][ODBC Driver 11 for SQL Server]TDS Protocol error 使用php 7.3的SQL Server的Microsoft ODBC驱动程序17失败并显示错误消息 - Microsoft ODBC Driver 17 for SQL Server with php 7.3 fails with false error message Laravel SQL Server: SQLSTATE[HY000]: [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]TDS 流中的协议错误 - Laravel SQL Server: SQLSTATE[HY000]: [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Protocol error in TDS stream PHP PDO Microsoft SQL Server:SQLSTATE [24000]:[Microsoft] [用于SQL Server的ODBC驱动程序11]-无效的游标状态 - PHP PDO Microsoft SQL Server: SQLSTATE[24000]: [Microsoft][ODBC Driver 11 For SQL Sever] - Invalid Cursor State SQLSTATE [42000]:[Microsoft] [用于SQL Server的ODBC驱动程序13] [SQL Server]'`'附近的语法不正确 - SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near '`'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM