An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied for user 'db_user'@'localhost' (using password: YES)
Solution 1
This method seem to not work for me I dont kniw why but it worked this way :
- So I used Flex to install doctrine :
composer require doctrine
Then I run this :
composer require orm
then I went to my file
.env
and I found my database syntax generated automaticlyy and everything worked fine .Also I deleted the other sql processors that were open on my computer ( i hv installed sql server too + wamp which explaine the conflict that I have) and then re-opened my wamp server and everything is working fine.
Solution 2
I think you have to create an user "db_user" with password in your DBMS. Then grant him with "Administration" rights. Then correct .env's database configuration line :
DATABASE_URL="mysql://db_user:[email protected]:3306/db_name"
Solution 3
Try using the same syntax like you have a password, just enter nothing where password suppose to be:
DATABASE_URL="mysql://root:@127.0.0.1:3306/db_school"
As it's explained here: https://github.com/doctrine/DoctrineBundle/issues/746#issuecomment-351788298
hafida Bo
Updated on November 05, 2020Comments
-
hafida Bo over 3 years
I followed this documentation to add doctrine to my symfony project(v4.2). But when doctrine is installed it deosn't add this line to my project ( in my .env file like mentioned in the doc ):
DATABASE_URL="mysql://db_user:[email protected]:3306/db_name"
So I added it manually like this :
DATABASE_URL="mysql://[email protected]:3306/db_school"
and used this commande to create the database :
php bin/console doctrine:database:create
and it gives me this error :
In AbstractMySQLDriver.php line 93: An exception occurred in driver: SQLSTATE[HY000] [1045] Access denied for user 'db_user'@'localhost' (using password: YES)
In PDOConnection.php line 31: SQLSTATE[HY000] [1045] Access denied for user 'db_user'@'localhost' (using password: YES)
In PDOConnection.php line 27: SQLSTATE[HY000] [1045] Access denied for user 'db_user'@'localhost' (using password: YES)Even I changed the user and password it still dosn't recognize it . Any idea why it dosn't work ? I will appreciate it .
-
hafida Bo about 5 yearsI just tried your suggestion but I still have the same probleme :
-
Nicolas about 5 yearsSearch the string "db_user" in all project's files and check if it exists only where it has to exists
-
hafida Bo about 5 yearsI searched but it doesn't exist . I don't know where the problem come from