0
votes

I'm kind of new with symfony and I'm trying to create a entity in through doctrine, I'm working on Windows and xampp.

In one cmd I have the server running (php bin/console server:run) in another cmd I tried to create the entity with php bin/console doctrine:generate:entity

It asks my for a entity shortcut name (BlogBundle:Post) after this I get three the same kind of errors;

SQLSTATE[HY000] [1045] access denied for user 'root'@'localhost' (using password: NO)

I googled and found that, because I already have databases in xampp, and changed the password. therefor I should change my password in the parameters.yml, which I did ( I also created an empty symfony database in phpMyAdmin);

# This file is auto-generated during the composer install
parameters:
    database_host: 127.0.0.1
    database_port: null
    database_name: symfony
    database_user: root
    database_password: mypassword
    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: null
    mailer_password: null
    secret: ac8be0befa84f2aeda5d2e9068a7ae2e948376fb

My doctrine part of my config.yml file looks like this;

# Doctrine Configuration
doctrine:
    dbal:
        driver: pdo_mysql
        host: '%database_host%'
        port: '%database_port%'
        dbname: '%database_name%'
        user: '%database_user%'
        password: '%database_password%'
        charset: UTF8
        # if using pdo_sqlite as your database driver:
        #   1. add the path in parameters.yml
        #     e.g. database_path: "%kernel.project_dir%/var/data/data.sqlite"
        #   2. Uncomment database_path in parameters.yml.dist
        #   3. Uncomment next line:
        #path: '%database_path%'

    orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true

After this I still get the three errors, only 'password: no' changed to 'password: yes';

SQLSTATE[HY000] [1045] access denied for user 'root'@'localhost' (using password: YES)

Can someone tell me whats going wrong and what I should change?

I already tried everything in SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) . changing host from 127.0.0.1 to localhost, changing port to 3306, putting the password in quotes and the SonataUserBundle part doesn't applies here.

1
Please check this answer specifically in that dupe: stackoverflow.com/a/27551131/367456 - And is there anything in the error message specific that is not so clear to you? Have you checked with the documentation of the database-server about the meaning of that error message (Mysql and/or Mariadb both have all error messages documented with additional information).hakre
There are many similar questions here on SO about that errror message in combination with Symfony and Doctrine. It seems to be hard to configure the password properly within the configuration files. In any case, I suggest to double check you're using the correct credentials and if so then to double check that the values don't get altered when encoded into the configuration files.hakre
I already tried everything in that question. changing host from 127.0.0.1 to localhost, changing port to 3306, putting the password in quotes and the SonataUserBundle part doesnt apply here.Loes Visser
the credentials are correct, I can login to myphpadmin with those credentials. how can I check if the password is not altered?Loes Visser
Good question. Perhaps this is character encoding related? Does Phpmyadmin accepts UTF-8 input? The yaml files in symfony are UTF-8, for the property files I'm not entirely sure. Another things might be with the YAML encoding itself, e.g. sindlge / double quotes. I suspect this is not so easy to debug until you find the culprit. So far the error message is clear however.hakre

1 Answers

4
votes

i had the same error thrown mysql, the solution is to wrapping password in single quote

    database_password: 'mypassword'