[英]SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from `cats`)
I am building a basic CRUD app using Laravel 7 Homestead in a Vagrant VM.我正在 Vagrant VM 中使用 Laravel 7 Homestead 构建一个基本的 CRUD 应用程序。 The root address
http://crud-app.local.test
works, but when I add a defined route ( http://crud-app.local.test/cats
) I get this error page:根地址
http://crud-app.local.test
有效,但是当我添加定义的路由( http://crud-app.local.test/cats
)时,我收到此错误页面:
Error message in browser when navigating to '/cats' route.导航到“/cats”路由时浏览器中的错误消息。
So far I have:到目前为止,我有:
.env
file and in practice.env
文件和实践中验证了我的 MySQL 密码匹配.env
file).env
文件中的内容匹配)php artisan config:cache
php artisan config:cache
php artisan config:clear
followed by php artisan cache:clear
php artisan config:clear
然后是php artisan cache:clear
127.0.0.1
to localhost
127.0.0.1
更改为localhost
.env
file exists ( crud
).env
文件中定义的数据库存在( crud
)php artisan migrate
(no errors, and the cats
table exists in the crud
database) php artisan migrate
(没有错误, crud
数据库中存在cats
表)vagrant reload --provision
)vagrant reload --provision
) I'm at a loss now.我现在不知所措。
Make sure that you give "root" permissions to read from the database that you've created.确保您授予“root”权限以读取您创建的数据库。 As it's root@localhost rather than root@127.0.0.1 sometimes mysql differentiates.
因为它是 root@localhost 而不是 root@127.0.0.1 有时 mysql 会有所不同。 Just check the permissions that root@localhost has for the database and if you update them, flush the privileges.
只需检查 root@localhost 对数据库的权限,如果您更新它们,请刷新权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.