2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

HerokuでLaravel+MySQLのプロジェクトをマイグレーションする時に詰まったこと

Posted at
$ heroku config | grep CLEARDB_DATABASE_URL

上記で表示されたDATABASE_URLを参考に環境変数を設定

$ heroku config:set DB_DATABASE=[データベース名]
$ heroku config:set DB_HOST=[ホスト名]
$ heroku config:set DB_USERNAME=[ユーザー名]
$ heroku config:set DB_PASSWORD=[パスワード]

マイグレーションを実行

$ heroku run php artisan migrate

下記のエラーが表示された
環境変数を確認しても間違いはなかった

SQLSTATE[HY000] [2002] No such file or directory 

調べたところ、unix_socketはlocalhost内で通信を行う際に使うみたいなので、config/database.phpファイル内のunix_socketのパスを削除。

config/database.php
'unix_socket' => env('DB_SOCKET', 'root'),
config/database.php
'unix_socket' => env('DB_SOCKET', ''),

無事にMysqlに接続できた

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?