Loes Visser
Loes Visser

Reputation: 31

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

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.

Upvotes: 0

Views: 9923

Answers (1)

Yecodeo
Yecodeo

Reputation: 371

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

    database_password: 'mypassword' 

Upvotes: 4

Related Questions