Laravel 5.1 - Homestead MySQL connection. `Connection Refused` & `No such file or directory`

本小妞迷上赌 提交于 2019-12-04 13:11:21
nathanmac

Inside the VM the sql port is 3306. Outside of the homestead VM the host machine just has a forward to the SQL port on the homestead VM. That is why 33060 points to 3306.

Laravel Homestead Vagrant Box Database Problems

To fix the issue. Do the following:

.env

DB_HOST=127.0.0.1 
 DB_PORT=3306
 DB_DATABASE=homestead
 DB_USERNAME=homestead
 DB_PASSWORD=secret

database.php

  'mysql' => [
        'driver'    => 'mysql',
        'host'      => env('DB_HOST', 'localhost'),
        'database'  => env('DB_DATABASE', 'homestead'),
        'username'  => env('DB_USERNAME', 'homestead'),
        'password'  => env('DB_PASSWORD', 'secret'),
        'port'      => env('DB_PORT', 3306),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ],

That will get your browsing fixed. Now to run artisan commands, just do vagrant SSH and run them on the VM.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!