尝试将 drush migrate-upgrade 与 DDEV 结合使用时连接被拒绝(Drupal 7 到 8 升级)

Connection refused when trying to use drush migrate-upgrade with DDEV (Drupal 7 to 8 upgrade)

我正在尝试使用 DDEV 在本地测试我的 运行 俱乐部的 Drubal 7 网站的升级。

我有一个包含网站副本的容器,下面的结果来自 DDEV 描述命令:

    URLs
    ----
    https://drupalTest.ddev.site:8003
    https://127.0.0.1:32773
    http://drupalTest.ddev.site:8002
    http://127.0.0.1:32774

    MySQL/MariaDB Credentials
    -------------------------
    Username: "db", Password: "db", Default database: "db"

    or use root credentials when needed: Username: "root", Password: "root"

    Database hostname and port INSIDE container: db:3306
    To connect to db server inside container or in project settings files:
    mysql --host=db --user=db --password=db --database=db
    Database hostname and port from HOST: 127.0.0.1:32771
    To connect to mysql from your host machine,
    mysql --host=127.0.0.1 --port=32771 --user=db --password=db --database=db

    Other Services
    --------------
    MailHog (https):        https://drupalTest.ddev.site:8026
    MailHog:                http://drupalTest.ddev.site:8025
    phpMyAdmin (https):     https://drupalTest.ddev.site:8037
    phpMyAdmin:             http://drupalTest.ddev.site:8036

我还有一个装有 Drupal 8 的容器(全新安装)。

    URLs
    ----
    https://drupal8migration.ddev.site:8017
    https://127.0.0.1:32769
    http://drupal8migration.ddev.site:8016
    http://127.0.0.1:32770

    MySQL/MariaDB Credentials
    -------------------------
    Username: "db", Password: "db", Default database: "db"

    or use root credentials when needed: Username: "root", Password: "root"

    Database hostname and port INSIDE container: db:3306
    To connect to db server inside container or in project settings files:
    mysql --host=db --user=db --password=db --database=db
    Database hostname and port from HOST: 127.0.0.1:32797
    To connect to mysql from your host machine,
    mysql --host=127.0.0.1 --port=32797 --user=db --password=db --database=db

    Other Services
    --------------
    MailHog (https):        https://drupal8migration.ddev.site:8026
    MailHog:                http://drupal8migration.ddev.site:8025
    phpMyAdmin (https):     https://drupal8migration.ddev.site:8037
    phpMyAdmin:             http://drupal8migration.ddev.site:8036

我在使用 drush migrate-upgrade 命令时遇到问题,这是

ddev exec drush migrate-upgrade --legacy-db-url=mysql://db:db@127.0.0.1:32771/db --legacy-root=https://drupalTest.ddev.site:8003 --configure-only

刚收到这个错误:

SQLSTATE[HY000] [2002] Connection refused                            [error]

感谢任何帮助

欢迎来到 ddev,马克!

你的问题是你在那里使用了错误的 --legacy-db-url。数据库的凭证将是:

host:旧版安装的容器名称(如 ddev--db)(不是 127.0.0.1) 端口:不需要指定,因为是默认的3306(在docker容器space内)

所以看起来你想要这样的东西: ddev exec drush migrate-upgrade --legacy-db-url=mysql://db:db@ddev-drupaltest-db/db --legacy-root=https://drupalTest.ddev.site:8003 --configure-only

参见“不同项目之间能否相互通信”下的faq

此外,您绝对想阅读 Migrating from Drupal 6 to Drupal 8 Like a Boss,这有助于理解迁移上下文中的所有这些内容。

我注意到您似乎为不同的项目使用不同的 http 端口 - 您根本不需要这样做。使用 ddev 的正常方法是将所有内容都放在端口 80 和 443 上(如果有冲突,则设置为其他端口集)。您 不需要 设置 router_http_port 或 router_https_port 只是为了 运行 同一主机上的多个项目。