Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bertmi01's avatar

SQLSTATE[HY000] [1045] Access denied for user...

Sorry if there is a clear answer on this, I searched all over before posting this...

background info:

So today I wanted to work on learning how to send mail through my app, and have Sparkpost configured and ready to send things for me. I updated my .env file and only edited the MAIL lines. At one point in configuring my app to send a test mail, I had to do either

php artisan config:clear
php artisan config:cache
php artisan cache:clear

This plus a reset of xampp nearly had my test email go out, but I realized I didn't have a security certificate to actually send the mail. That's fine, I'll figure it out later (will learn how to test mail locally first).

current issue:

So now I just try to log back into my app and I get:

SQLSTATE[HY000] [1045] Access denied for user 'USERNAME'@'localhost' (using password: YES) (SQL: select * from `users` where `email` = EMAIL_ADDRESS limit 1)

Then I try to run any artisan command:

 PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'USERNAME'@'localhost' (using password: YES)")
      C:\xampp\htdocs\Project\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:68

  2   PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=DATABASE", "USERNAME", "PASSWORD", [])
      C:\xampp\htdocs\Project\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:68

I have absolutely no idea what to do here. I didn't knowingly change any settings for the database/MySQL. All threads I could find with these errors simply say to run the config:clear command and restart the server and everything should be fine, but it's not in my case.

Any ideas? I'm completely at a loss. Anything at all would be sincerely appreciated.

0 likes
6 replies
jlrdw's avatar

This plus a reset of xampp

Exactly what do you mean a reset of xampp.

bertmi01's avatar

@jlrdw Click "stop" for apache and mySQL, wait for them to be stopped, then click "Start" for both.

jlrdw's avatar

AH, you restarted services, fine.

I updated my .env file and only edited the MAIL lines.

Change back just to ensure all is still working.

Also when you restarted the services, make sure all started. I use similar, a bitnami wamp stack, and once the mysql service took longer to start.

Try accessing mysql from commandline and make sure it's working.

bertmi01's avatar

@jlrdw I just tried it but there seems to be no difference.

It seems mysql is working OK from the command line too.

jlrdw's avatar
jlrdw
Best Answer
Level 75

seems mysql is working OK from the command line too

It should work in laravel, are you sure you did not create a typo in that env file, or somewhere. Do you have more than one mysql installed.

2 likes
bertmi01's avatar

@jlrdw Thanks for mentioning the possibility of a typo - I can only guess that I must have accidentally clicked and entered some text in my long db password in the .env file. I switched the credentials to root with no password and everything works fine.

Thanks for the help!

Please or to participate in this conversation.