LoginSignup
4
5

More than 5 years have passed since last update.

Laravel5のhomesteadのDB設定

Last updated at Posted at 2015-04-29

homesteadのmigrateでエラーが出たらDB_HOSTにポート番号をつける。

% php artisan migrate

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

.env
DB_HOST=localhost:33060
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=pass
% php artisan migrate
Migration table created successfully.
Migrated: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_100000_create_password_resets_table

※追記

MySQL: 33060 -> Forwards To 3306

してるんだからエラーでいい気がした。
当たり前だけど今度はブラウザからDB繋ぐとエラーになるし。

homestead ssh でサーバー入ってphp artisan migratesすればいいだけじゃないか。

やっぱ戻す。

.env
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=pass

↑でApp::runningInConsole()でコマンドからかブラウザからか切り分けて変なif分書いてるけどそんなんなるべく書きたくないよね。

4
5
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
4
5