dscizpq790832708 2018-12-01 17:05
浏览 285

将laravel项目部署到azure时出现SQL SSL错误

I deployed the project to azure and both the webpage displays properly and links work fine, but for the user registration I need to connect the database. Everything works well locally and I followed all the instructions of creating/connecting a sqsl db in azure but I get thte following 3 errors and not sure what to do, how to debug, its a project I was given to deply and didnt create myself,( I am only gona show the first 3 lines of the error since they are long):

UPDATE: It works if I disable the SSL on azure so its got something to do with my local app config for that

1-

 SQLSTATE[HY000] [9002] SSL connection is required. Please specify SSL options and retry. (SQL: select count(*) as aggregate from `users` where `email` = ***@***.com)

in Connection.php line 647
at Connection->runQueryCallback('select count(*) as aggregate from `users` where `email` = ?', array('***@***.com'), object(Closure))
in Connection.php line 607

2-

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

in PDOConnection.php line 50
at PDOConnection->__construct('mysql:host=***.mysql.database.azure.com;port=**+;dbname=uwiredb', '***@***', 'MySQLAzure2017', array(0, 2, 0, false, false))
in Connector.php line 65
at Connector->createPdoConnection('mysql:host=***.mysql.database.azure.com;port=***;dbname=***', '***@***', 'MySQLAzure2017', array(0, 2, 0, false, false))
in Connector.php line 44

3-

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

here is the DB section of my .env file:

    DB_CONNECTION=mysql
    DB_HOST=mydbserver.mysql.database.azure.com
    DB_DATABASE=mydb
    DB_USERNAME=myuser
    DB_PASSWORD=mypass
    MYSQL_SSL=true

And here is the connection part of my database.php file in the config folder, I know the hosts

 'connections' => [

'sqlite' => [
    'driver' => 'sqlite',
    'database' => env('DB_DATABASE', database_path('database.sqlite')),
    'prefix' => '',
],

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'homestead'),
    'username' => env('DB_USERNAME', 'homestead'),
    'password' => env('DB_PASSWORD', ''),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => '',
    'strict' => true,
    'engine' => null,
    'sslmode' => env('DB_SSLMODE', 'prefer'),
    'options' => (env('MYSQL_SSL')) ? [
        PDO::MYSQL_ATTR_SSL_KEY    => '/ssl/BaltimoreCyberTrustRoot.crt.pem', 
    ] : [],
],

'pgsql' => [
    'driver' => 'pgsql',
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '5432'),
    'database' => env('DB_DATABASE', 'forge'),
    'username' => env('DB_USERNAME', 'forge'),
    'password' => env('DB_PASSWORD', ''),
    'charset' => 'utf8',
    'prefix' => '',
    'schema' => 'public',
    'sslmode' => 'prefer',
],

'sqlsrv' => [
    'driver' => 'sqlsrv',
    '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' => '',
],

],

I know the host is set to local but that is how I understood it should be from the azure docs that say:

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:

PHP

Copy
'mysql' => [
    'driver'    => 'mysql',
    'host'      => env('DB_HOST', 'localhost'),
    'database'  => env('DB_DATABASE', 'forge'),
    'username'  => env('DB_USERNAME', 'forge'),
    'password'  => env('DB_PASSWORD', ''),
    ...
],

Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向