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

Jashandeep1229's avatar

SQLSTATE[HY000] [1049] Unknown database

(Mac User) Any Command of Laravel got error showing unknown database but when I run on the web browser (localhost:8080/yoursite) its work perfectly fine but I want to migrate the database so that is why I want to resolve this problem

I am using xampp and homebrew server

Please Help Me

0 likes
8 replies
MichalOravec's avatar

Did you set .env file for your database?

This is default, set them.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

If so then run

php artisan config:clear
1 like
Jashandeep1229's avatar

php artisan config:clear same error unknown database

but on a web browser, its perfectly work fine (localhost:8080/yoursite)

my .env file:-

DB_CONNECTION=mysql

DB_HOST=127.0.0.1

DB_PORT=3306

DB_DATABASE=yoursite

DB_USERNAME=root

DB_PASSWORD=

MichalOravec's avatar

What name of database do you get after Unknown database?

1 like
Jashandeep1229's avatar

yoursite but you must think about how works fine on the web browser that means database connection is fine but any command of laravel don't work like migration config: clear or any commands

MichalOravec's avatar

And did you create that database?

Check if you have a file bootstrap\cache\config.php. If so remove it.

1 like
Jashandeep1229's avatar

No, I don't have file config.php it only two files one is the packages.php, and the other is the services.php

Jashandeep1229's avatar

Still error But when i change db conmetion - 127.0.0.1 to 127.0.0.1:8080 On terminal, its showing different error that is mysql has gone away But on web browser, db connection is refused

Please or to participate in this conversation.