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

房东的猫 提交于 2019-12-11 10:49:13

问题


I am trying to upload website on cpanel. The following error is encountering

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

My .env file contains:

    APP_ENV=local
APP_DEBUG=true
APP_KEY=4ZuW70AMILLsnvHkTJ1yraRoGqmx4Dzg

    DB_HOST=localhost
    DB_DATABASE=campaign
    DB_USERNAME=hassan
    DB_PASSWORD=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 config/database.php as

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

What might be wrong with it?


回答1:


The second paramater of env function contains a default value, which is used if the needed constant is not found.

In your case, you specify constant DB_PASSWORD and use value password.

Did you intend to use value China125?

Either remove that constant completely from .env file in order to use your default, or set it to China125:

DB_HOST=localhost
DB_DATABASE=campaign
DB_USERNAME=hassan
DB_PASSWORD=China125


来源:https://stackoverflow.com/questions/30200208/pdoexception-in-connector-php-line-47-sqlstatehy000-1045-access-denied-for

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