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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49167436/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:29:02  来源:igfitidea点击:

"SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' : Laravel

laraveldenied

提问by Bibek

I am unable to register a user accountin a Laravel project.

我无法在 Laravel 项目中注册用户帐户

Error

错误

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

Is there a solution?

有解决办法吗?

回答by Prashant Prajapati

Make sure that you update the below values in your .env file:

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

DB_CONNECTION=mysql

DB_HOST=127.0.0.1

DB_PORT=3306

DB_DATABASE=your_database_name

DB_USERNAME=root

DB_PASSWORD=

Once updated .env file, stop the server of your project and serve the project again using the php artisan servecommand.

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

回答by Abhilash.k.p

You have to make changes in the .envfile for the following fields:

您必须在.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