gpt4 book ai didi

php - 教义迁移-连接被拒绝

转载 作者:行者123 更新时间:2023-12-02 19:30:02 30 4
gpt4 key购买 nike

我无法使用Symfony 4上的Doctrine Migration bundle 包。我在Docker容器中启动Web应用程序。在容器启动后要执行迁移的尝试上,迁移失败并显示“连接被拒绝”异常。但:

  • 当我尝试从主机或FPM容器连接到它自己的容器中的MySQL时,它可以正常工作
  • 执行使用Doctrine的命令后,它可以正常工作。

  • 例:
    root@3af0cf70b099:/var/www# php bin/console doctrine:migration:migrate -qn

    In StreamSocketClient.php line 225:

    Failed to write to socket: fwrite(): send of 185 bytes failed with errno=111 Connection refused (8)


    doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--db DB] [--em EM] [--shard SHARD] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<version>]

    root@3af0cf70b099:/var/www# php bin/console dbtest


    [OK] Found user with login demo


    root@3af0cf70b099:/var/www# php bin/console doctrine:migration:migrate -qn

    In StreamSocketClient.php line 225:

    Failed to write to socket: fwrite(): send of 185 bytes failed with errno=111 Connection refused (8)


    doctrine:migrations:migrate [--write-sql [WRITE-SQL]] [--dry-run] [--query-time] [--allow-no-migration] [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--db DB] [--em EM] [--shard SHARD] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<version>]

    root@3af0cf70b099:/var/www#

    迁移仅在容器启动后超过20秒后才能进行。
    我的学说配置:
    doctrine:
    dbal:
    # configure these for your database server
    driver: '%env(DB_DRIVER)%'
    server_version: '%env(DB_SERVER_VERSION)%'
    charset: '%env(DB_CHARSET)%'
    default_table_options:
    charset: '%env(DB_CHARSET)%'
    collate: '%env(DB_COLLATION)%'
    mapping_types:
    enum: string
    types:
    phone_number: Misd\PhoneNumberBundle\Doctrine\DBAL\Types\PhoneNumberType
    url: 'mysql://%env(DB_USER)%:%env(MYSQL_ROOT_PASSWORD)%@%env(DB_HOST)%:%env(DB_PORT)%/%env(MYSQL_DATABASE)%'
    orm:
    auto_generate_proxy_classes: false
    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

    教义迁移配置是默认设置:
    doctrine_migrations:
    dir_name: '%kernel.project_dir%/src/Migrations'
    # namespace is arbitrary but should be different from App\Migrations
    # as migrations classes should NOT be autoloaded
    namespace: DoctrineMigrations

    最佳答案

    您需要等待所有docker服务完全加载。
    另请:https://docs.docker.com/compose/startup-order/

    关于php - 教义迁移-连接被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52351744/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com