0

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

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Mohammed
  • 79
  • 1
  • 2
  • 5
  • does your database has the correct user? – Wouter Van Damme Jul 23 '19 at 14:15
  • Looks like a similar issue as this https://stackoverflow.com/questions/20353402/access-denied-for-user-testlocalhost-using-password-yes-except-root-user – Edwin Krause Jul 23 '19 at 14:16
  • Just a hunch but try using `127.0.0.1` instead of `localhost` in your `.env` file. Also try connecting directly via CLI to remove as many factors as possible like old config files. – user1669496 Jul 23 '19 at 15:41
  • Does this answer your question? [MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost' (using password: YES)](https://stackoverflow.com/questions/10299148/mysql-error-1045-28000-access-denied-for-user-billlocalhost-using-passw) – miken32 Nov 05 '21 at 20:22

3 Answers3

0

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.

  • thank you but the file still does not accept the update with new information i do not know why [Illuminate\Database\QueryException] SQLSTATE[HY000] [1045] Access denied for user 'xxxx'@'localhost' (using password: YES) (SQL: select * from `countries`) [PDOException] SQLSTATE[HY000] [1045] Access denied for user 'xxxx'@'localhost' (using password: YES) – Mohammed Jul 23 '19 at 14:44
  • The project contains different data such as Username: xxxx Password: xxxx Database user name: xxxx You have changed the old data but the project did not accept the update – Mohammed Jul 23 '19 at 14:47
0
  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
RISHIKESH PAL
  • 226
  • 2
  • 7
0

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