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 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题