从AWS / RDS Maria DB 10.0迁移Symfony 3.3.12失败:DBALException

时间:2018-06-23 18:54:04

标签: symfony doctrine dbal

我试图迁移使用Symfony 3.3.12制作的API,该API使用具有基于MariaDb MariaDB 10.0.24的Amazon RDS的数据库安装在AWS上

在我的日志上获取:

[2018-06-23 18:22:52] request.INFO: Matched route "api_login_check". {"route":"api_login_check","route_parameters":{"_route":"api_login_check"},"request_uri":"https://api.excellenting.com/api/login_check","method":"POST"} []
[2018-06-23 18:22:54] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\DBALException: "An exception occured while establishing a connection to figure out your platform version. You can circumvent this by setting a 'server_version' configuration value  For further information have a look at: https://github.com/doctrine/DoctrineBundle/issues/673" at /home/ubuntu/symfony_backend/vendor/doctrine/doctrine-bundle/ConnectionFactory.php line 96 {"exception":"[object] (Doctrine\\DBAL\\DBALException(code: 0): An exception occured while establishing a connection to figure out your platform version.\nYou can circumvent this by setting a 'server_version' configuration value\n\nFor further information have a look at:\nhttps://github.com/doctrine/DoctrineBundle/issues/673 at /home/ubuntu/symfony_backend/vendor/doctrine/doctrine-bundle/ConnectionFactory.php:96, Doctrine\\DBAL\\Exception\\ConnectionException(code: 0): An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused at /home/ubuntu/symfony_backend/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:108, Doctrine\\DBAL\\Driver\\PDOException(code: 2002): SQLSTATE[HY000] [2002] Connection refused at /home/ubuntu/symfony_backend/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:47, PDOException(code: 2002): SQLSTATE[HY000] [2002] Connection refused at /home/ubuntu/symfony_backend/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:43)"} []
[2018-06-23 18:53:39] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "HEAD /"" at /home/ubuntu/symfony_backend/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php line 123 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"HEAD /\" at /home/ubuntu/symfony_backend/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php:123, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0):  at /home/ubuntu/symfony_backend/var/cache/prod/appProdProjectContainerUrlMatcher.php:1585)"} []

好吧,我看不到,或者我不了解有关的信息。

但是我正在调查,并且看到Syfony 3.3 Doctrine manual谈到了这个问题,进一步的搜索显示MariaDB 10.2.7及更高版本存在问题。

好吧,我在原始API上将MariaDb降级为相同版本:

好吧,我编辑了app/config/config.yml,尝试使用5.6和5.2(这是mysql -Version的逻辑值返回

# Doctrine Configuration
doctrine:
    dbal:
        driver:   pdo_mysql
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        server_version: 5.6
        charset:  UTF8

mysql -Version
mysql  Ver 15.1 Distrib 10.0.35-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

配置中的凭据正确无误,并尝试使用端口3306,主机到localhost的其他版本...

parameters:
    database_host: 127.0.0.1
    database_port: null
    database_name: c1farid
    database_user: c1fariduser
    database_password: CorrectPassWorD

1 个答案:

答案 0 :(得分:0)

更简单。

bin/console cache:clear --env=prod
// Clearing the cache for the prod environment with debug false


[OK] Cache for the "prod" environment (debug=false) was successfully cleared.

不做任何修改,只有我忘记了Exception Doctrine \ DBAL \ DBALException中的 stupid 消息错误。