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

后端 未结 3 882
终归单人心
终归单人心 2020-12-18 16:59

I´m working with symfony 2.1.2, FOSuserBundle, SonataAdminBundle, SonataUserBundle and SonataMediaBundle. The problem is that I cannot access to my database and get this err

3条回答
  •  隐瞒了意图╮
    2020-12-18 17:21

    In your app/config/parameters.yml

    # This file is auto-generated during the composer install
    parameters:
        database_driver: pdo_mysql
        database_host: 127.0.0.1
        database_port: 3306
        database_name: symfony
        database_user: root
        database_password: "your_password"
        mailer_transport: smtp
        mailer_host: 127.0.0.1
        mailer_user: null
        mailer_password: null
        locale: en
        secret: ThisTokenIsNotSoSecretChangeIt
    

    database_password should be inside double quoted (") or single quoted (').

    I have seen most of users happen this because they are using password with leading zero or numeric (in my situation its like that)


    And also I have tried with localhost and double quoted passwords, its not working.

    So in that case use

    database_host: 127.0.0.1
    

    instead of

    database_host: localhost
    

提交回复
热议问题