Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?

More than 1 year has passed since last update.

@tommy0218

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

  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
参考になればと思います。

0
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What is going on with this article?