简体   繁体   English

Symfony 与 DDEV CLI 数据库连接

[英]Symfony with DDEV CLI db connection

I want to start a Symfony Project using docker !我想使用 docker 开始一个 Symfony 项目! I tried to build it using DDEV CLI!我尝试使用 DDEV CLI 构建它! https://ddev.readthedocs.io/en/stable/users/cli-usage/ https://ddev.readthedocs.io/en/stable/users/cli-usage/

I used the standard configuration from DDEV.我使用了 DDEV 的标准配置。 (php) (php)

As soon as I want to make:只要我想做:

php bin/console make:migration

I got:我有:

  An exception occurred in driver: SQLSTATE[HY000] [2002] php_network_getaddresses: 
  getaddrinfo failed: nodename nor servname provided, or not known  

.env file: .env 文件:

 DATABASE_URL="mysql://db:db@db:3306/db?serverVersion=10.2"

When I change the host to: 127.0.0.1 in.env:当我将主机更改为:127.0.0.1 in.env:

 DATABASE_URL="mysql://db:db@127.0.0.1:3306/db?serverVersion=10.2"

I got:我有:

   An exception occurred in driver: SQLSTATE[HY000] [2054] The server requested 
   authentication method unknown to the client  

DDEV config.yaml DDEV config.yaml

  name: bib
  type: php
  docroot: public
  php_version: "7.3"
  webserver_type: nginx-fpm
  router_http_port: "80"
  router_https_port: "443"
  xdebug_enabled: false
  additional_hostnames: []
  additional_fqdns: []
  provider: default
  use_dns_when_possible: true

Kindly ask for help in this Regards.请在这方面寻求帮助。

You need to run all such commands from within the ddev container, either through a SSH terminal ( ddev ssh opens a shell in the container), or as an ad-hoc command ( ddev exec php bin/console make:migration ). You need to run all such commands from within the ddev container, either through a SSH terminal ( ddev ssh opens a shell in the container), or as an ad-hoc command ( ddev exec php bin/console make:migration ).

This is needed because the hostnames used to communicate between one container and any other are only resolve from within the containers itself这是必需的,因为用于在一个容器和任何其他容器之间进行通信的主机名只能从容器本身内解析

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ddev 和 TYPO3:如何为多个开发人员处理数据库和文件管理 - ddev and TYPO3: how to handle the DB and fileadmin for multiple developers ddev 设置中除 web 和 db 容器之外的其他 SQL Server db 容器 - Additional SQL Server db container in ddev setup beside web and db container IBM DB2 连接从 docker 到 python 抛出 [IBM] [CLI 驱动程序] SQL1598N - IBM DB2 connection from docker through python throwing [IBM][CLI Driver] SQL1598N ZFS 上的 ddev:服务“db”构建失败:复制文件失败:复制文件范围失败:参数无效 - ddev on ZFS: Service 'db' failed to build : failed to copy files: copy file range failed: invalid argument 对于 ddev-mautic-db 无法为服务 db 创建容器:“bind”类型的挂载配置无效:绑定源路径不存在 - for ddev-mautic-db Cannot create container for service db: invalid mount config for type "bind": bind source path does not exist Symfony + Docker,连接被拒绝 - Symfony + Docker, connection refused 在Windows 10 Home上,ddev启动不会启动-无法为服务db创建容器:类型“ bind”的无效安装配置 - On Windows 10 Home ddev start does not start - Cannot create container for service db: invalid mount config for type “bind” Laravel - 未连接到 docker 上的 DB - Laravel - not connection to DB on docker Docker DB连接被拒绝 - Docker DB connection refused DDEV - ddev 启动后 - 出现错误 - DDEV - after ddev start - it cames Errors
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM