LoginSignup
demilio
@demilio

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]

解決したいこと

xxx@xxxx:~/example-app$ vendor/bin/sail php artisan migrate
と入力すると下記エラー文が表示されます。
エラーの内容が理解できません。
エラーをなくしたいです。よろしくお願いいたします。

発生している問題・エラー

 Illuminate\Database\QueryException 

  SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = example_app and table_name = migrations and table_type = 'BASE TABLE')

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

      +39 vendor frames 
  40  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

自分で試したこと

.envを削除して復元しました。

0

1Answer

あなたの環境について具体的な記載がないので、詳しい回答は難しいです。
データベースやプログラミング言語、フレームワークなどについての基本的な情報は最低限記載したほうがよいです。

よくあるのは次のようなことを確認します。

  • データベースは起動しているか
  • 他の方法で接続できるか(mysqlコマンドやMySQL Workbenchなどのクライアントツール)

またLaravelを使用しているようなので、次の点を確認します。

  • 環境変数(.envファイル等)に正しい接続情報が設定されているか
  • Laravelの設定に正しく反映されているか(envメソッドで取得できる値を確認する)
1Like

Comments

  1. @demilio

    Questioner
    ご指摘ありがとうございます。
    無事解決いたしました。

Your answer might help someone💌