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

Flex's avatar
Level 4

[PDOException] SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'f orge'

I have been download github laravel project and going to create data tables in My localhost. with php artisan migrate command occured following error massage on My cmd.

[PDOException]
SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'f
orge'

how can I fix this problem?

0 likes
4 replies
Lars-Janssen's avatar

Try 127.0.0.1 instead of localhost. Is your db name forge and password correct?

mcangueiro's avatar

From that error it doesn't seem your app knows about the database user. Make sure your database credentials on your .env file are correct.

Cronix's avatar

and make sure there isn't a space in "forge" like you currently have. Is there a db user that you're supposed to be logging in as? It's not set.

Cronix's avatar

Are all of these settings filled out properly for your db and user in your .env file?

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=forge
DB_USERNAME=homestead
DB_PASSWORD=secret

Please or to participate in this conversation.