LoginSignup
1
0

More than 3 years have passed since last update.

LaravelでMySQLに接続しようとした際に起きたエラー(SQLSTATE[HY000] [2002] Connection refused)

Last updated at Posted at 2020-04-15
  Illuminate\Database\QueryException 

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

上記のようなエラーが出ました。

主の環境

・MAMP環境
・PHPとLaravelは最新

行ったこと

DB_CONNECTION=mysql
DB_HOST=localhost:8889
DB_PORT=3306
DB_DATABASE=laravel_db
DB_USERNAME=root
DB_PASSWORD=root

DB_HOST=の部分をlocalhost:8889
に変更したらうまくいった。
ネット上に記載されていることを一通り試してみたがうまくいかずダメもとでHOSTの部分をphpmyadminに記載されていたサーバーのホスト通りに.envに記載したらうまくいった。
スクリーンショット 2020-04-15 17.55.49.png
参考になればと思います。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0