Symfony Doctrine: Unable to create database

1

I'm following this tutorial:

  

link

and I get this error:

  

Could not create database symfony for connection named default An   exception occurred in driver: SQLSTATE [HY000] [1045] Access denied for   user 'root' @ 'localhost' (using password: YES)

The .env file is set up like this:

  

DATABASE_URL="mysql: // root: [email protected]: 3306 / symfony? charset = utf8mb4 & serverVersion = 5.7"

To access mysql (I have it thanks to mamp), I gave the root a password; Well, my questions are:

  • 1) Should I put it in the above connection chain where I put XXXXXX? Should I put it in double quotes?
  • 2) Can I omit the creation of the database using the command:

      

    ./ bin / console doctrine: database: create

    and create it myself using the phpMysqlAdmin or another BD manager? Would this second form of creation affect the correct functioning of the symfony application?

Thanks in advance.

Greetings, Abelardo.

    
asked by Abelardo León González 09.09.2017 в 13:29
source

1 answer

1

In your config file you must have defined your EntityManagers which have associated credentials and drivers for the connection.

Example Doctrine Configuration: doctrine: dbal: default_connection: default connections: default: server_version: 5.7 driver: "%database_driver%" host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: utf8 mapping_types: bit: boolean enum: string

You must choose the environment in which you are working that will refer to your config_prod, dev, local file and therefore to an entity manager with one configuration or another. If you do not add the parameter --env go to the one you have by default, probably prod

The command in symfony 3: ./bin/console doctrine:database:create --env=local

The command in symfony 2: ./app/console doctrine:database:create --env=local

The env parameter is in case you have different environments: test, prod, local ...

    
answered by 15.09.2017 в 12:43