I deleted the migrations
table from a Laravel 5.4 database named laravel
. When I run php artisan migrate:install
, I get this error:
[Illuminate\Database\QueryException] SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations)
I deleted and recreated the database. I also ran composer update
. No luck. I can run the command in phpMyAdmin and create the table manually.
This problem sometimes also manifests itself with similar 2002 errors:
[Illuminate\Database\QueryException] SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: No such host is known. (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
[Illuminate\Database\QueryException] SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')
If you are using localhost
as your DATABASE_HOST
in the .env
file, change it to 127.0.0.1
, then run php artisan config:clear
and now try php artisan migrate:install
again.
Here's what I recommend for .env
file:
DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306
Then in Database.php
add folder location:
'unix_socket' => env('DB_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'),
Finally, try:
php artisan config:clear php artisan migrate:install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With