Php artisan migrate no such file or directory

Aaron picture Aaron · Apr 28, 2017 · Viewed 22.5k times · Source

I created a make:migration when I try to run the migration I get the following error

No such file or directory (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations).

In my env file my db name is homestead and in my db I have a table named migrations. Not really sure why I am getting this error.

Answer

Maxim Safioulline picture Maxim Safioulline · Jun 23, 2017

Here is what worked for me. I am using Homestead vagrant box, along with a bunch of other Vagrant boxes and Docker images for various projects, so the IP of my Homestead box was not 127.0.0.1, it was 192.168.10.10. I was getting variations of SQLSTATE[HY000] [2002] until I updated the IP address in int .env file to

DB_CONNECTION=mysql
DB_HOST=192.168.10.10
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

and my config/database.php with

'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '192.168.10.10'),
        'port' => env('DB_PORT', '3306'),
...

I also ran php artisan cache:clear and php artisan config:clear after the changes. After that running

php artisan migrate

returned

Migration table created successfully.

Hope it helps someone. You can check the IP of your Homestead machine in Homestead/Homestead.yaml file.