LoginSignup
2
0

More than 5 years have passed since last update.

[ エラー ] Larvel [PDOException] SQLSTATE[HY000] [2002] Connection refused

Last updated at Posted at 2018-05-15

php artisan migrateをコマンド実行した際のエラー

初歩的なところでエラーになったので、メモとして書いておきます。

$ vagrant up

$ vagrant ssh

のコマンドを実行した後に

$ php artisan migrate

を実行するとエラーに。

[PDOException]
SQLSTATE[HY000] [2002] Connection refused

原因はvagrantファイル内で実行していなかった為(ディレクトリが間違っていた)
なので、cd コマンドでファイル内に移動

$ cd default (vagrant内のファイル名)

これで php artisan migrate コマンドを打てば実行される

違うエラー

vagrant upでこのエラーが出た場合
私の場合、対処は上記と同じでしたが、
VagrantとVirtualBoxとの紐付けがちゃんと出来ていない事があるみたいです。

A Vagrant environment or target machine is required to run this command. 
Run `vagrant init` to create a new Vagrant environment. 
Or, get an ID of a target machine from `vagrant global-status` to run this command on. 
A final option is to change to a directory with a Vagrantfile and to try again.
2
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
2
0