PDO Exception while setting database username and password

I am using Laravel 5 and mysql. The following error is coming while setting username and password.

PDOException in Connector.php line 47: SQLSTATE[HY000] [1045] Access denied for user 'some_username'@'localhost' (using password: YES)

The content of my .env file is

APP_ENV=local
APP_DEBUG=true
APP_KEY=4ZuW70AMILLsnvHkTJ1yraRoGqmx4Dzg

DB_HOST=localhost
DB_DATABASE=some_database
DB_USERNAME=some_username
DB_PASSWORD=some_password

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null

and my config/database.php contains:

    'mysql' => [
        'driver'    => 'mysql',
        'host'      => env('DB_HOST', 'localhost'),
        'database'  => env('DB_DATABASE', 'some_database'),
        'username'  => env('DB_USERNAME', 'some_username'),
        'password'  => env('DB_PASSWORD', 'some_password'),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
        'strict'    => false,
    ],

In phpMyAdmin I have created a user with same credentials. What might be wrong with it?

链接地址: http://www.djcxy.com/p/33064.html

上一篇: HTML字符编码接受UTF

下一篇: 设置数据库用户名和密码时发生PDO异常