Lumen中的命令未与AWS RDS连接

问题描述 投票:0回答:1

我在Elastic Beanstalk中使用带有PHP 7.2的Lumen 5.7应用程序,有几个端点正常工作,在RDS中获取和插入数据。但是一个Lumen命令(我创建的)是tryng连接到localhost,忽略了环境配置。我通过ssh执行这个命令。

我收到了这个错误:

[2019-03-29 18:37:01] production.ERROR: PDOException: SQLSTATE[HY000] [2002] Connection refused in /var/app/current/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27
Stack trace:
#0 /var/app/current/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(27): PDO->__construct('mysql:host=127....', 'forge', '', Array)
#1 /var/app/current/vendor/illuminate/database/Connectors/Connector.php(67): Doctrine\DBAL\Driver\PDOConnection->__construct('mysql:host=127....', 'forge', '', Array)
#2 /var/app/current/vendor/illuminate/database/Connectors/Connector.php(46): Illuminate\Database\Connectors\Connector->createPdoConnection('mysql:host=127....', 'forge', '', Array)
#3 /var/app/current/vendor/illuminate/database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection('mysql:host=127....', Array, Array)

它正在尝试使用用户伪造连接到127.0.0.1。服务器中没有.env文件。本地命令正常工作。有谁可以帮助我吗?

编辑:我已经添加了config / database.php文件和下一个代码

return [
    'default' => 'mysql',
    'connections' => [
        'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST'),
            'database' => env('DB_DATABASE'),
            'username' => env('DB_USERNAME'),
            'password' => env('DB_PASSWORD'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
        ]
    ],

    'migrations' => 'migrations',

];

现在我收到这个错误:

production.ERROR: InvalidArgumentException: Database hosts array is empty. in /var/app/current/vendor/illuminate/database/Connectors/ConnectionFactory.php:203

编辑2我再次部署,我现在收到此错误:

[2019-03-30 01:12:53] local.ERROR: PDOException: SQLSTATE[HY000] [1045] Access denied for user 'user'@'xx.xx.xx.xx' (using password: YES) in /var/app/current/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27
Stack trace:
#0 /var/app/current/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php(27): PDO->__construct('mysql:host=dev-...', 'user', 'mypass...', Array)
#1 /var/app/current/vendor/illuminate/database/Connectors/Connector.php(67): Doctrine\DBAL\Driver\PDOConnection->__construct('mysql:host=dev-...', 'user', 'mypass...', Array)
#2 /var/app/current/vendor/illuminate/database/Connectors/Connector.php(46): Illuminate\Database\Connectors\Connector->createPdoConnection('mysql:host=dev-...', 'user', 'mypass...', Array)
#3 /var/app/current/vendor/illuminate/database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection('mysql:host=dev-...', Array, Array)
#4 /var/app/current/vendor/illuminate/database/Connectors/ConnectionFactory.php(182): Illuminate\Database\Connectors\MySqlConnector->connect(Array)

连接数据是正确的,但用户出现服务器ip [email protected],我不知道这是否正确。

amazon-web-services lumen amazon-elastic-beanstalk
1个回答
0
投票

密码包含'$'字符。出于某种原因,Lumen在此角色之前截断了密码。它被删除了,一切都恢复了。

© www.soinside.com 2019 - 2024. All rights reserved.