且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQLSTATE [HY000] [1045]用户'username'@'localhost'的访问被拒绝(使用密码:是)

更新时间:2021-08-04 21:23:50

解决方案:



有时,更改.env时,如果没有清除缓存或重新启动服务器,配置将不会刷新。

The solution:

Sometimes when you change your .env, the configs don't refresh without clear cache or restarting the server.

错误消息是:

SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: YES)

尝试从缓存的 .env配置中获取信息,您应该尝试:

The database are trying to get the information from the "cached" .env configuration, you should try:

php artisan config:clear

如果无法解决,请重新启动服务器。

if not solve, restart your server.


  • 转到您的 config\database.php

  • 删除.env配置

并设置自己的凭据

'mysql' => [
            'host' => '45.55.88.77',
            'database' => 'prod',
            'username' => 'forge',
            'password' => '*********',
        ],