0

Using

        "php": "^7.1.3",
        "doctrine/doctrine-bundle": "^1.11",
        "doctrine/doctrine-fixtures-bundle": "^3.1",
        "doctrine/doctrine-migrations-bundle": "^2.0",
        "doctrine/orm": "^2.6",
        "friendsofsymfony/oauth-server-bundle": "^1.6",
        "friendsofsymfony/rest-bundle": "^2.5",
        "friendsofsymfony/user-bundle": "^2.1",
        "jms/serializer-bundle": "^3.3",
        "symfony/asset": "4.2.*",
        "symfony/yaml": "4.2.*"

I cannot seem to get my configuration correct to connect my Symfony Doctrine PHP API to my MySQL database on AWS DB instance. I am running Ubuntu 16+ on all my instances. I am able to connect my local API to my local MySQL without any problems, and I am able to connect my testing server in the same way, but when I move to my production server on AWS, and I try to run the following:

php bin/console doctrine:schema:update --force --env=prod --complete

I get the following error:

In AbstractMySQLDriver.php line 93: An exception occurred in driver: SQLSTATE[HY000] [2002] No such file or directory

I have tried multiple configuration settings and many searches, but in almost all cases the issues were with settings using localhost versus 127.0.0.1, and that is not my issue as I am trying to connect from an AWS EC2 (hosting my API) to an AWS DB instance.

I have checked multiple times and my username, database, password, and path configurations are correct, I have tested them via manual login to the DB instance.

Here is the config in my config/packages/doctrine.yaml


    doctrine:
        dbal:
            # configure these for your database server
            driver: 'pdo_mysql'
            server_version: '5.7'
            charset: utf8
            default_table_options:
                charset: utf8
                collate: utf8_unicode_ci
            host: 'api-database.XXXXXXXXXXX.ca-central-1.rds.amazonaws.com'
            port: '3306'
            dbname: 'XXXXXXX'
            user: 'XXXXX'
            password: 'XXXXXXXXXXXXXXXXXXXXXXX'
        orm:
            auto_generate_proxy_classes: true
            naming_strategy: doctrine.orm.naming_strategy.underscore
            auto_mapping: true
            mappings:
                App:
                    is_bundle: false
                    type: annotation
                    dir: '%kernel.project_dir%/src/Entity'
                    prefix: 'App\Entity'
                    alias: App
    monolog:
        handlers:
            main:
                type: stream
                path: '%kernel.logs_dir%/%kernel.environment%.log'
                level: debug
                channels: ['!event']

I should be able to connect to the database and run the migrations to update the database schema.

  • Possible dupe of: https://stackoverflow.com/questions/48135522/symfony-4-doctrine-not-working-from-console-2002-no-such-file-or-directory or https://stackoverflow.com/questions/39935545/symfony3-sqlstatehy000-2002-no-such-file-or-directory?rq=1 – RyanNerd Jun 27 '19 at 19:57
  • Thanks RyanNerd, but as I stated in my post, I am not trying to connect to a local database, so the localhost -> 127.0.0.1 solution, which is the solution in both of the possible dupes you listed, is not relevant to my question. –  Jun 28 '19 at 11:26

1 Answers1

0

I am not sure what happened, but it started working after I rebooted my server (I did a reboot because I updated some security packages). Seems my configuration, which I did not change, was correct, so there might have been a cache issue or some other related problem.