0

Since this morning, I'm trying to connect Symfony to mySQL.

this is my .env :

DATABASE_URL=mysql://root:@127.0.0.1:3306/shop?serverVersion=5.7
DATABASE_USER=root
DATABASE_PWD=root
DATABASE_NAME=shop
DATABASE_HOST=127.0.0.1

this is my doctrine.yaml :

dbal:

# configure these for your database server
    driver: 'pdo_mysql'
    server_version: '5.7'
    charset: utf8mb4
    host: 127.0.0.1
    port: 3306
    user: '%env(DATABASE_USER)%'
    password: '%env(DATABASE_PWD)%'
    dbname: '%env(DATABASE_NAME)%'


  

When I'm doing the command : bin/console doctrine:database:create

I have the error : In CreateDatabaseDoctrineCommand.php line 82:

Connection does not contain a 'path' or 'dbname' parameter and cannot be created.

Can anyone have any idea of what is wrong ?

thanks

1 Answers1

0

Try using in your .env:

DATABASE_URL=mysql://root:root@127.0.0.1:3306/shop

In your doctrine.yaml:

doctrine:
    dbal:
        # configure these for your database server
        url: '%env(resolve:DATABASE_URL)%'

See https://symfony.com/doc/current/doctrine.html#configuring-the-database

Manzolo
  • 1,909
  • 12
  • 13