Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel php artisan migrate Error (timeout)

I am using Laravel 5.6

when I use the command 'php artisan migrate' I get this error (after a minute) :

"Illuminate\Database\QueryException : SQLSTATE[HY000] [2002] Operation timed out (SQL: select * from information_schema.tables where table_schema = MYDATABASE and table_name = migrations)"

I have set up the correct database configuration in .env and config/database.php

I checked that my db connection works : if(DB::connection()->getDatabaseName()) { echo "Yes! successfully connected to the DB: " . DB::connection()->getDatabaseName(); }

And it works.

if i run the query directly in mysql, it will not work because of the lack of quotes. if instead I run this in mysql it will work:

select * from information_schema.tables where table_schema = 'MYDATABASE' and table_name = 'migrations'

the issue in php artisan seem to be : "Operation timed out" (not the usual "File not found" when i tried to look for an answer here.

How to solve the php artisan migrate issue ??? thank you!


like image 681
khalil Avatar asked Nov 17 '22 19:11

khalil


1 Answers

I had this same problem and it turned out my host was incorrect.

In my .env file I set DB_HOST to the correct value and it all worked like a charm.

like image 58
amflare Avatar answered Dec 06 '22 02:12

amflare