不可能连接我的symfony 5应用程序与mysql: postgresql是强制的



我正在使用最新的php7.4.12和Apache,我不明白它是什么,我搜索这个错误:"驱动程序中发生异常:SQLSTATE[08006][7]无法连接到服务器:Connection refused
服务器是否运行在主机"127.0.0.1"并在5432端口上接受TCP/IP连接?">

In my .env

DATABASE_URL="mysql://root:@db_docker_symfony:3306/test_docker?serverVersion=5.7"

和doctrine.yaml

dbal:
url: '%env(resolve:DATABASE_URL)%'
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '13'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'AppEntity'
alias: App

我有同样的问题,基本上你可能有postgresql未注释…这个端口5432是与postgresql连接相关的,所以你只需要用"#"注释掉这一行。…如下所示,

# DATABASE_URL ="postgresql://db_user: db_password@127.0.0.1:5432/db_name ? serverVersion = 13, charset = utf8"

只留下未注释的mysql连接,然后砰!快乐的日子嘿o/…

我认为。env是postgresql的默认连接。

希望对你也有用。

最新更新