dongwen7423 2016-09-19 18:01
浏览 43
已采纳

Doctrine MySQL Error 1045(使用密码:NO),即使有密码也没问题

I keep getting this when trying to create a database in Doctrine (I'm using Symfony 3.1.4):

An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)`

From what I gather, this error pops up when trying to connect to MySQL when the user has no password or it's incorrect. But this is not my case.

parameters.yml is as follows:

# This file is auto-generated during the composer install parameters:
database_host: 127.0.0.1
database_port: 8080
database_name: symfony_db
database_user: root
database_password: password
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: secret`

And config.yml...

# Doctrine Configuration
doctrine:
    dbal:
        driver:   pdo_mysql
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8`

So, nothing seems to be wrong here. MySQL does have a password, and the one in parameters.yml is exactly the same I use in phpmyadmin and used to work when using Laravel.

Thanks in advance.

  • 写回答

1条回答 默认 最新

  • doudou201701 2016-09-20 14:33
    关注

    So, I managed to fix it.

    As mentioned in the comments, I did skim through the Symfony installation instructions to change it all later in parameters.yml, but what happened was that Symfony didn't do anything new when I change config.yml and parameters.yml, only the initial parameters stood.

    And I finally found out why, courtesy of some helpful person on the #symfony IRC channel: while I was changing configurations, the wrong information I initially inserted during installation was cached, so all I had to do was to run php bin/console doctrine:cache:clear on the command line before connecting.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn