'PDOException',消息'SQLSTATE [HY000] [1045]访问被拒绝[LARAVEL]

时间:2016-06-20 23:17:52

标签: php laravel laravel-5.2

我正在对数据库做一些记录,并不时出现这个错误:

local.ERROR: exception 'PDOException' with message 'SQLSTATE[HY000]
[1045] Access denied for user 'homestead'@'localhost'
(using password: YES)' in
:\WEB\litraen\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:55

我有文件env。正确配置。

ENV。

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=auth
DB_USERNAME=root
DB_PASSWORD=

1 个答案:

答案 0 :(得分:0)

请检查config/database.php是否

'default' => env('DB_CONNECTION', 'mysql'),

在连接数组中

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