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.