phplaravellaravel-artisanhomesteadartisan-migrate

I cant migrate database - Homestead


When i type php artisan migrate from my pc it throws an error.

1 D:\xampp\htdocs\cms\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70 PDOException::("SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it")

2 D:\xampp\htdocs\cms\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=cms", "homestead", "secret", [])

But when I ssh into homestead with vagrant ssh migration works.


Solution

  • You just need to edit your .env file to look like this

    DB_CONNECTION=mysql
    DB_HOST=ip that you specified inside your Homested.yaml
    DB_PORT=3306
    DB_DATABASE=db_name
    DB_USERNAME=homestead --- default homestead db username
    DB_PASSWORD=secret    --- default homestead db passwprd