1

I'm using laravel 5.2 and I have problem with migrations . ( I am a beginner )

when I create a table, there is no problem, but when I run php artisan migrate this error show up :

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

my env file data :

DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=root
DB_PASSWORD=

my config/database.php file :

'mysql' => [
        'driver'    => 'mysql',
        'host'      => env('DB_HOST', 'localhost'),
        'database'  => env('DB_DATABASE', 'homestead'),
        'username'  => env('DB_USERNAME', 'root'),
        'password'  => env('DB_PASSWORD', ''),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
        'engine'    => null,
],

my app env use 'local' , but I can't run this command .

I'm just running php -S localhost:8888 -t public to access localhost and I don't run anything else . should I run anything else ?

pre thanks for your help .

2 Answers 2

1

yes. you should setup a database for the application. The configurations you posted assumes that there is a local mysql database server running and there is a database called 'homestead'. so Unknown database 'homestead' is just means what is says.

if you dont have a local mysql server, you can use sqlite which laravel supports as well.

Edit: if you have a mysql server then just create a database called 'homestead' or whatever you like then change the configurations accordingly.

Alternatively, use the full stack that Laravel offers and consider using Homestead with Vagrant.

Sign up to request clarification or add additional context in comments.

Comments

0

Create database in mysql and change DB_DATABASE=homestead to DB_DATABASE=your_database name

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.