“ Illuminate \ Database \ QueryException:SQLSTATE [HY000] [2002]连接被拒绝”来自虚拟机的Laravel连接

时间:2018-06-26 22:45:09

标签: mysql virtual-machine laravel-5.6 connection-refused

我有Laravel 5.6并尝试从我的虚拟机连接到MySql,但是当我尝试“ php artisan migration”时会出现此错误:

“ Illuminate \ Database \ QueryException:SQLSTATE [HY000] [2002]连接被拒绝”

我的配置很好,因为我可以从主机上进行配置,但是不能从我的虚拟机上进行。

Mysql用户拥有所有权限,并且我具有以下配置:  confing / database.php:

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

config.env

DB_CONNECTION=mysql
DB_HOST=(myIp like x.x.x.x)
DB_PORT=3306
DB_DATABASE=DB_laravel
DB_USERNAME=DB_laravel
DB_PASSWORD=xxxxxx

0 个答案:

没有答案