[英]Doctrine MySQL Error 1045 (Using Password: NO) even though there is a password and it's correct
I keep getting this when trying to create a database in Doctrine (I'm using Symfony 3.1.4): 尝试在Doctrine中创建数据库时,我一直收到此消息(我正在使用Symfony 3.1.4):
An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)` 驱动程序中发生异常:SQLSTATE [HY000] [1045]用户'root'@'localhost'的访问被拒绝(使用密码: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. 据我所知,当用户没有密码或密码不正确时,尝试连接到MySQL时会弹出此错误。 But this is not my case. 但这不是我的情况。
parameters.yml is as follows: parameters.yml如下:
# 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... 和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. MySQL确实有一个密码,而parameters.yml中的密码与我在phpmyadmin中使用的密码完全相同,并且在使用Laravel时可以正常使用。
Thanks in advance. 提前致谢。
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. 就像评论中提到的那样,我确实浏览了Symfony安装说明,稍后再在parameters.yml中对其进行更改,但是发生的是,当我更改config.yml和parameters.yml时,Symfony并没有做任何新的事情,只有初始的参数不变。
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. 最后,我发现了原因,在#symfony IRC频道上有人帮助:在我更改配置时, 缓存了我最初在安装过程中插入的错误信息 ,因此我要做的就是运行php bin/console doctrine:cache:clear
连接前在命令行上php bin/console doctrine:cache:clear
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.