PHP Laravel:拒绝访问用户 '宅' @ 'localhost' 的(使用密码:YES)

问题描述 投票:0回答:3

有人可以解释为什么我得到这个错误,以及如何解决这个问题?我看了几计算器一样的问题,但仍然无法正常工作。

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

我.ENV文件

APP_ENV=local
APP_KEY=base64:pAoq6D+Xq2VXHQ9/z1f2ecd5gD104FfBnp5w/UVTV0Q=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

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

PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=

感谢您的关注。

链接我读过:

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

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

Access denied for user 'homestead@localhost' .. in laravel 5

php mysql laravel homestead
3个回答
3
投票

尝试清除缓存配置,如:

php artisan config:cache

0
投票

你尝试到数据库值分配给DB_FIELDS?

DB_DATABASE=Database
DB_USERNAME=Username 
DB_PASSWORD=Password

例:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=to-do-app-db
DB_USERNAME=root
DB_PASSWORD=""

另一种选择:php artisan config:clear


0
投票

所有的细节,你需要根据你的MySQL服务器上进行配置。

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

因为如果你使用的是XAMPP例如,去你的phpmyadmin,设置用户帐户,让您的用户名和密码。默认情况下,它会作为根用户名和密码为空。

© www.soinside.com 2019 - 2024. All rights reserved.