BLOG
Laravel初期設定でDB接続エラーが発生
php artisan migrate
を実行すると、
SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql failed: nodename nor servname provided, or not known (SQL: select * from information_schema.tables where table_schema = matching and table_name = migrations and table_type = 'BASE TABLE')
というエラーが発生。
.env の DB_HOST=mysql を DB_HOST=localhost に変更して再度 php artisan migrate すると、
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = matching and table_name = migrations and table_type = 'BASE TABLE')
と、エラーメッセージの内容が変わる。
次に .env の DB_HOST=localhost を DB_HOST=127.0.0.1 に変更し再度 php artisan migrate すると、成功。
原因が分からないのですが、一旦メモしておきます。