简体   繁体   English

SQLSTATE[HY000] [1045] 用户 'root'@'localhost' 的访问被拒绝(使用密码:YES)(SQL:从 `cats` 中选择 *)

[英]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:到目前为止,我有:

  • Verified my MySQL password matches in the .env file and in practice.env文件和实践中验证了我的 MySQL 密码匹配
  • Changed the MYSQL password so that it's no longer empty (and made sure it matches what's in the .env file)更改了 MYSQL 密码,使其不再为空(并确保它与.env文件中的内容匹配)
  • Ran php artisan config:cachephp artisan config:cache
  • Ran php artisan config:clear followed by php artisan cache:clearphp artisan config:clear然后是php artisan cache:clear
  • Changed 127.0.0.1 to localhost127.0.0.1更改为localhost
  • Made sure the database defined in the .env file exists ( crud )确保.env文件中定义的数据库存在( crud
  • Ran php artisan migrate (no errors, and the cats table exists in the crud database) Ran php artisan migrate (没有错误, crud数据库中存在cats表)
  • Restarted and re-provisioned the machine ( 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.

相关问题 SQL: select * from users: SQLSTATE[HY000] [1045] 用户 'root'@'localhost' 访问被拒绝(使用密码:YES) - SQL: select * from users: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) SQLSTATE [HY000] [1045] 用户'root'@'localhost'的访问被拒绝(使用密码:NO)(SQL:select *来自`permissions`) - SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: select * from `permissions`) SQLSTATE[HY000] [1045] 用户 'homestead'@'localhost' 的访问被拒绝(使用密码:YES)(SQL:从 `table` 中选择 *) - SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES) (SQL: select * from `table`) SQLSTATE [HY000] [1045] 用户'root'@'localhost'的访问被拒绝(使用密码:YES)symfony2 - SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) symfony2 无法迁移 SQLSTATE[HY000] [1045] 用户 'root'@'localhost' 的访问被拒绝(使用密码:YES) - Cannot migrate SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) Symfony-理论:用户'root'@'localhost'的SQLSTATE [HY000] [1045]访问被拒绝(使用密码:是) - Symfony - doctrine: SQLSTATE[HY000] [1045] access denied for user 'root'@'localhost' (using password: YES) Illuminate\Database\QueryException: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (使用密码: YES) - Illuminate\Database\QueryException : SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) SQLSTATE [HY000] [1045]拒绝用户'root'@'localhost'的访问(使用密码:是)错误 - SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) error occurs SQLSTATE[HY000] [1045] 用户'root'@'localhost'的访问被拒绝(使用密码:YES)? - SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)? SQLSTATE[HY000] [1045] 用户 'root'@'localhost' 的访问被拒绝(使用密码:NO)(SQL:select * from `rooms` order by `order_by` asc) - SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: select * from `rooms` order by `order_by` asc)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM