@tabe187 (Toru Abe)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed~の解消法を教えて下さい。

解決したいこと

laravelの開発環境を構築している際に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 = database02 and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:759
    755▕         // If an exception occurs when attempting to run a query, we'll format the error
    756▕         // message to include the bindings with SQL, which will make this exception a
    757▕         // lot more helpful to the developer instead of just the database's errors.
    758▕         catch (Exception $e) {
  ➜ 759▕             throw new QueryException(
    760▕                 $query, $this->prepareBindings($bindings), $e
    761▕             );
    762▕         }
    763▕     }


自分で試したこと

最初に表示されていたエラーメッセージ

SQLSTATE[HY000] [1045] Access denied for user 'user01'@'172.17.0.1' (using password: YES) (SQL: select * from information_schema.tables where table_schema = database02 and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:759
    755▕         // If an exception occurs when attempting to run a query, we'll format the error
    756▕         // message to include the bindings with SQL, which will make this exception a
    757▕         // lot more helpful to the developer instead of just the database's errors.
    758▕         catch (Exception $e) {
  ➜ 759▕             throw new QueryException(
    760▕                 $query, $this->prepareBindings($bindings), $e
    761▕             );
    762▕         }
    763▕     }

.envファイルのDB_HOSTを"mysql"に変更いたところ、前者のエラーメッセージが表示されるようになりました。

0 likes

No Answers yet.

Your answer might help someone💌