php artisan migrate laravel 5.3给我PDOException] SQLSTATE [HY000] [2002]连接拒绝

时间:2016-12-04 19:40:57

标签: php mysql laravel-5.3

我是laravel 5.3的新手,并试图为用户表运行php artisan migrate,我正在使用带有MAMP的macbook。

database.php文件如下所示:

    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', 'localhost'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'mydb'),
        'username' => env('DB_USERNAME', 'root'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,

.env看起来像这样:

DB_CONNECTION=mysql 
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydb
DB_USERNAME=root
DB_PASSWORD=

我没有使用DB的密码,我从项目库运行" php artisan migrate"得到: PDOException] SQLSTATE [HY000] [2002]连接被拒绝

1 个答案:

答案 0 :(得分:0)

我在mysql部分添加了database.php:

'unix_socket'   => '/Applications/MAMP/tmp/mysql/mysql.sock',   

现在正在运作