Laravel 5 error SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

Solution 1:

It's working now. I had to restart server. Thanks

Solution 2:

I was facing the same issue. Everything was fine but in

bootstrap/cache/config.php

always had the incomplete password. Upon digging further, realized that the password had '#' character in it and that was getting dropped. As '#' is used to mark a line as a comment.

Solution 3:

You need to run these two commands

php artisan cache:clear
php artisan config:cache

Solution 4:

I spent hours on this :-( and finally, it was really easy to hack

BEFORE

DB_PASSWORD=#Root2020$

UPDATED

DB_PASSWORD="#Root2020$"

I think the problem was # in the password, that's why I had to write my password into quotation marks.

Solution 5:

None of these worked for me when I deployed my website online on shared hosting, below is what I did that worked.

In the .env file, I changed

DB_HOST=127.0.0.1

to

DB_HOST=localhost

and viola, it worked well as expected.