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

david-c's avatar

PDOException SQLSTATE[28000] [1045] Access denied for user

Going round and round on this. Wasted almost 2 hours on this so far. 5.2 install, fairly fresh. Might have started as a repo install, but ran composer over it to make sure things were updated.

User name / password appear correct and I can hit the DB from the command line using same credentials. Using the database.php and have tried both "localhost" as well as "127.0.0.1". I clear both caches after any changes (php artisan cache:clear, config:cache).

I am using bootstrap/environment.php file to smartly load up a .dev.env file that has the base information, including the APP_KEY.

exact error: at PDO->__construct('mysql:host=127.0.0.1;port=3306;dbname=system', '**', '', array('0', '2', '0', false, '0')) in Connector.php line 55

Funny part is that it was working at some point because I had another install that had a migration from the "task" exercise. So there is something somewhere that is causing a problem. I am considering just blowing this out of the water since there is no real work done in it yet. Proof Of concept on how I can integrate Laravel with the Legacy code base.

0 likes
3 replies
zachleigh's avatar
Level 47

Look at the line in Connector where it is faulting:

$pdo = new PDO($dsn, $username, $password, $options);

And then from the error message:

'mysql:host=127.0.0.1;port=3306;dbname=system', '**', '', array('0', '2', '0', false, '0')

Your username and password are not being read properly. Show us the code where you load the .env file.

david-c's avatar

I blew it all out, redid everything and it worked.

My best guess is there was a special char that got inserted via copy/paste between puTTY and netbeans. It's working now, and I am off in search of how to seamlessly interact with multiple schema. It's looking like I should setup named connections for each schema.

screwtape_mk's avatar

Hey guys im having a similar problem. Have cleared cache etc but the problem persists. i do understand that the username and password are not being read properly but what changes must be made then

Please or to participate in this conversation.