“主义:模式:验证”消息:“驱动程序中发生异常:SQLSTATE [HY000] [2002]没有这样的文件或目录”

问题描述

有人可以教我如何在docker容器环境中的shell上运行symfony迁移吗?

登录到我的应用容器

$ docker exec -it 79dcd1240fdf /bin/bash

然后运行

bin/console doctrine:schema:validate 

仅接收

sqlSTATE[HY000] [2002] No such file or directory

我能够登录到我的数据库容器并从那里访问数据库,所以由于数据库存在而感到困惑吗?

$ docker exec -it bd96edcb1164 /bin/bash

I have no name!@bd96edcb1164:/$ MysqL -h localhost -P 4307 -u andy -ppassword symfony_red
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.23-MariaDB Source distribution

copyright (c) 2000,2018,Oracle,MariaDB Corporation Ab and others.

MariaDB [symfony_red]> show databases
 -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| symfony_red        |
| test               |
+--------------------+
3 rows in set (0.001 sec)

MariaDB [symfony_red]> 

这是我的docker配置:

# docker-compose.yml
version: '2'

services:
 myapp:
 image: 'docker.io/bitnami/symfony:1-debian-10'
 ports:
   - '8000:8000'
 volumes:
   - '.:/app'
 depends_on:
   - mariadb
 mariadb:
  image: 'docker.io/bitnami/mariadb:10.3-debian-10'
  environment:
   - ALLOW_EMPTY_PASSWORD=yes
   - MARIADB_USER=andy
   - MARIADB_DATABASE=symfony_red
   - MARIADB_PASSWORD=password
  ports:
   - "4307:3306"

和我的.env配置:-

# .env.local
DATABASE_URL=MysqL://andy:password@localhost:4307/symfony_red?serverVersion=5.7

我已经尝试将127.0.0.1切换为localhost-只是切换了另一个错误

sqlSTATE[HY000] [2002] Connection refused

帮助?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)