“SQLSTATE [HY000] [1045]访问被拒绝用户'root'@'localhost':Laravel

时间:2018-03-08 07:17:46

标签: laravel denied

无法在 laravel 项目中注册用户帐户

错误

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select count(*) as aggregate from `users` where `email` = xxx@xx.com)

任何解决方案???

2 个答案:

答案 0 :(得分:4)

确保更新.env文件中的以下值

DB_CONNECTION=mysql

DB_HOST=127.0.0.1

DB_PORT=3306

DB_DATABASE=your_database_name

DB_USERNAME=root

DB_PASSWORD= 

更新.env文件后停止项目的服务并使用php artisan serve命令再次为项目服务

答案 1 :(得分:1)

您必须在以下字段的 .env 文件中进行更改

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE= your database name
DB_USERNAME= your user name
DB_PASSWORD= your password