'"SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' : Laravel 5.3

Hi I'm having a problem with laravel 5.3 project was moved from one host to another and I've updated the .env file

The project was working well in the old host but when I moved to the new host, the site displaying this error

1/2

PDOException in Connector.php line 119: SQLSTATE[HY000] [1045] Access denied for user 'xxxx'@'localhost' (using password: YES)

2/2

QueryException in Connection.php line 770: SQLSTATE[HY000] [1045] Access denied for user 'xxxx'@'localhost' (using password: YES) (SQL: select * from countries)

xxxx => The user name for the old database was not updated. i do not know the reasonenter image description here



Solution 1:[1]

There are many possible reasons to throw this exception, let's explore them:

  1. There is a kind of cache in the .env file. In this case, you could only rewrite the DB variables, run php artisan config:clear and restart the server.
  2. Maybe some of the DB variables aren't right. In this case, you could check out the values.
  3. The user is right but he hasn't permission to access the database. In this case, you could check out the user permissions.

I hope that one of these tips help you.

Solution 2:[2]

  1. Check the .env file it should include all value like CONNECTION, HOST, PORT, etc.
  2. php artisan config:clear
  3. composer dump-autoload and restart the server

Solution 3:[3]

the SQLSQLSTATE[HY000] [1045] seems like the password in your .env file doesn't match with the database's password.

You can check the database pass and user in the new server and put into your .env file.

Good luck

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vinícius Alonso
Solution 2 RISHIKESH PAL
Solution 3 Christian Castro