sql ssl错误

66bbxpm5  于 2021-06-18  发布在  Mysql
关注(0)|答案(0)|浏览(356)

我将这个项目部署到azure,网页显示正常,链接工作正常,但是对于用户注册,我需要连接数据库。一切都在本地运行良好,我遵循了在azure中创建/连接sqsl db的所有说明,但我发现以下3个错误,不知道该怎么做,如何调试,这是一个项目,我被交给了deply,没有自己创建,(我只会显示错误的前3行,因为它们很长):
更新:如果我禁用了azure上的ssl,它就可以工作了,因此它与我的本地应用程序配置有关
1-

  1. SQLSTATE[HY000] [9002] SSL connection is required. Please specify SSL options and retry. (SQL: select count(*) as aggregate from `users` where `email` =***@***.com)
  2. in Connection.php line 647
  3. at Connection->runQueryCallback('select count(*) as aggregate from `users` where `email` = ?', array('***@***.com'), object(Closure))
  4. in Connection.php line 607

2-

  1. (2/3) PDOException
  2. SQLSTATE[HY000] [9002] SSL connection is required. Please specify SSL options and retry.
  3. in PDOConnection.php line 50
  4. at PDOConnection->__construct('mysql:host=***.mysql.database.azure.com;port=**+;dbname=uwiredb', '***@***', 'MySQLAzure2017', array(0, 2, 0, false, false))
  5. in Connector.php line 65
  6. at Connector->createPdoConnection('mysql:host=***.mysql.database.azure.com;port=***;dbname=***', '***@***', 'MySQLAzure2017', array(0, 2, 0, false, false))
  7. in Connector.php line 44

3-

  1. (1/3) PDOException
  2. SQLSTATE[HY000] [9002] SSL connection is required. Please specify SSL options and retry.

以下是my.env文件的db部分:

  1. DB_CONNECTION=mysql
  2. DB_HOST=mydbserver.mysql.database.azure.com
  3. DB_DATABASE=mydb
  4. DB_USERNAME=myuser
  5. DB_PASSWORD=mypass
  6. MYSQL_SSL=true

这里是config文件夹中database.php文件的连接部分,我知道主机

  1. 'connections' => [
  2. 'sqlite' => [
  3. 'driver' => 'sqlite',
  4. 'database' => env('DB_DATABASE', database_path('database.sqlite')),
  5. 'prefix' => '',
  6. ],
  7. 'mysql' => [
  8. 'driver' => 'mysql',
  9. 'host' => env('DB_HOST', '127.0.0.1'),
  10. 'port' => env('DB_PORT', '3306'),
  11. 'database' => env('DB_DATABASE', 'homestead'),
  12. 'username' => env('DB_USERNAME', 'homestead'),
  13. 'password' => env('DB_PASSWORD', ''),
  14. 'unix_socket' => env('DB_SOCKET', ''),
  15. 'charset' => 'utf8mb4',
  16. 'collation' => 'utf8mb4_unicode_ci',
  17. 'prefix' => '',
  18. 'strict' => true,
  19. 'engine' => null,
  20. 'sslmode' => env('DB_SSLMODE', 'prefer'),
  21. 'options' => (env('MYSQL_SSL')) ? [
  22. PDO::MYSQL_ATTR_SSL_KEY => '/ssl/BaltimoreCyberTrustRoot.crt.pem',
  23. ] : [],
  24. ],
  25. 'pgsql' => [
  26. 'driver' => 'pgsql',
  27. 'host' => env('DB_HOST', '127.0.0.1'),
  28. 'port' => env('DB_PORT', '5432'),
  29. 'database' => env('DB_DATABASE', 'forge'),
  30. 'username' => env('DB_USERNAME', 'forge'),
  31. 'password' => env('DB_PASSWORD', ''),
  32. 'charset' => 'utf8',
  33. 'prefix' => '',
  34. 'schema' => 'public',
  35. 'sslmode' => 'prefer',
  36. ],
  37. 'sqlsrv' => [
  38. 'driver' => 'sqlsrv',
  39. 'host' => env('DB_HOST', 'localhost'),
  40. 'port' => env('DB_PORT', '1433'),
  41. 'database' => env('DB_DATABASE', 'forge'),
  42. 'username' => env('DB_USERNAME', 'forge'),
  43. 'password' => env('DB_PASSWORD', ''),
  44. 'charset' => 'utf8',
  45. 'prefix' => '',
  46. ],

],
我知道主机被设置为本地,但这就是我从azure文档中理解它的方式:

  1. You can use the PHP getenv method to access the settings. the Laravel code uses an env wrapper over the PHP getenv. For example, the MySQL configuration in config/database.php looks like the following code:
  2. PHP
  3. Copy
  4. 'mysql' => [
  5. 'driver' => 'mysql',
  6. 'host' => env('DB_HOST', 'localhost'),
  7. 'database' => env('DB_DATABASE', 'forge'),
  8. 'username' => env('DB_USERNAME', 'forge'),
  9. 'password' => env('DB_PASSWORD', ''),
  10. ...
  11. ],

谢谢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题