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

aeltaib's avatar

[1049] Unknown database

Hi

When I enter command "php artisan migrate", the issue "[1049] Unknown database" appear, although I put the permission in the environment path in the control panel, so how can I solve it.

0 likes
11 replies
abusalameh's avatar

check if you've created the database and it matches the configurations in .env file

1 like
aeltaib's avatar

I did it, but when put the command the issue appear as:

[Illuminate\Database\QueryException] SQLSTATE[HY000] [1049] Unknown database 'associations' (SQL: select * from information_schema.tables where table_schema = associations and table_name = migration s)

[PDOException] SQLSTATE[HY000] [1049] Unknown database 'associations'

MaverickChan's avatar

because you did not create a database or did not set up correctly in your env file.

1 like
aeltaib's avatar

This is the config. on (env.) file

DB_CONNECTION=mysql

DB_HOST=127.0.0.1

DB_PORT=3306

DB_DATABASE=associations

DB_USERNAME=root

DB_PASSWORD=

aeltaib's avatar
aeltaib
OP
Best Answer
Level 1

Issue solved after creating DB command:

mysql -uroot -p

create database [DB name]; use [DB name];

Thanks for ur support

1 like
mianshargeel's avatar

Please can u explain me i have same issue but i don't understand how u solved ? i m getting same error like..

[Illuminate\Database\QueryException] SQLSTATE[HY000] [1049] Unknown database 'laravel_5' (SQL: select * from information_schema.tab les where table_schema = laravel_5 and table_name = migrations) [PDOException] SQLSTATE[HY000] [1049] Unknown database 'laravel_5'

laravel_5 is my DB name

aeltaib's avatar

@mianshargeel sorry for late answer :)

you just open "cmd" or command prompt & go to your project path then write the commands as:

mysql -uroot -p

then write:

create database [DB name];

then write:

use [DB name];

between [DB name] write your database name, for example:

use association;

  • 'association' here is my database name.
1 like
adirgapalit's avatar

HI, it works, hoever, this does not make us can manage database using mysqlworkbench. I tried it, but i can see, the project on my local does not represent the db on mysql work bench. Any idea?

Please or to participate in this conversation.