Login to your mysql server and create the database with the following command
create database tutorial;
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
OK I have been following the Laravel 5.7 From Scratch (first of all it is a very nice series - Bravo), and I have done everything according to the series to the point where a "php artisan migrate" command is issued. I receive the below issue:
$ php artisan migrate
Illuminate\Database\QueryException : SQLSTATE[HY000] [1049] Unknown database 'tutorial' (SQL: select * from information_schema.tables where table_schema = t utorial and table_name = migrations)
at C:\Users\motle\code\myfirstsite\vendor\laravel\framework\src\Illuminate\Dat abase\Connection.php:664 660| // If an exception occurs when attempting to run a query, we'll format the error 661| // message to include the bindings with SQL, which will make th is exception a 662| // lot more helpful to the developer instead of just the databa se's errors. 663| catch (Exception $e) {
664| throw new QueryException( 665| $query, $this->prepareBindings($bindings), $e 666| ); 667| } 668|
Exception trace:
1 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[HY000] [1049] Unknown databa se 'tutorial'") C:\Users\motle\code\myfirstsite\vendor\doctrine\dbal\lib\Doctrine\DBAL\Dri ver\PDOConnection.php:31
2 PDOException::("SQLSTATE[HY000] [1049] Unknown database 'tutorial'") C:\Users\motle\code\myfirstsite\vendor\doctrine\dbal\lib\Doctrine\DBAL\Dri ver\PDOConnection.php:27
Please use the argument -v to see more details.
Here is my configuration on my PC:
Windows 10 Home MySQL Apache 2.4 Laravel (set up as instructed by the "Scratch" series told me to. PHP 7.3 Created a new "connection" in MySQL Workbench and then put all the correct values in the .env file in Laravel so that it looks like:
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=tutorial DB_USERNAME=root DB_PASSWORD=********** (I put the password here just don't want to advertise it to everyone)
O.K. - Yes I am a newbie to Laravel, but following the series makes it easy. However, when I ran into the above issue, I have tried to find out if other people ran into this issue and they did. Following the trail, it is mostly due to people did not change the .env and they did not create the database. However, this is not the case here.
It seemed back in 2015 someone also posted this same issue and the answer provided to them did not work for me. Also since the "world" has evolved a great deal from 2015, I thought I would bring this up again.
So I am looking for the answer that will work today with Laravel 5.7 where in Windows 10, the database is there in MySQL and the .env has been changed to reflect this new database. However, no matter what I attempt, the migrate still fails. Again, I have followed the "Scratch" series to the letter and want to continue on with it. However, I need to have the ability to access the DB I set up and have the migrate work.
Any and all help is greatly appreciated.
Thank you in advance.
Login to your mysql server and create the database with the following command
create database tutorial;
Please or to participate in this conversation.