laravel - SQLSTATE[HY000] [1698] 用户 'hadi'@'localhost' 的访问被拒绝
问题描述
目前我在我的 Linux 操作系统中安装 laravel 8 没有任何错误,所以我开始研究一个简单的博客文章应用程序,当我运行时php artisan migrate
我收到以下错误。
Illuminate\Database\QueryException
SQLSTATE[HY000] [1698] Access denied for user 'hadi'@'localhost' (SQL: select * from information_schema.tables where table_schema = blog and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
667▕ // If an exception occurs when attempting to run a query, we'll format the error
668▕ // message to include the bindings with SQL, which will make this exception a
669▕ // lot more helpful to the developer instead of just the database's errors.
670▕ catch (Exception $e) {
➜ 671▕ throw new QueryException(
672▕ $query, $this->prepareBindings($bindings), $e
673▕ );
674▕ }
675▕
+34 vendor frames
35 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
我在这里和其他网站搜索我的问题,但找不到确切的解决方案。希望能得到一个
解决方案
检查您的文件 .env。确保其正确。
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_username
DB_PASSWORD=your_password
如果您输入了正确的凭证,但它仍然无法正常工作,您可以:
从 root/boostrap/chache/files 中删除缓存文件并运行应用程序
推荐阅读
- javascript - 在 MainActivity.java 中找不到 REACT-NATIVE 的方法 getPackages()
- swift - SwiftUI:如何更改 Slider 的范围?
- css - 禁用弹出背景滚动
- r - 在 R Shiny 中使用 renderUI 时,如何使我的 selectizeInput 持久化?
- android - 具有多个布局的 RecyclerView 未正确更新或在新数据上崩溃
- c# - c# XDocument.Root.Add 不添加任何元素
- c - 在 C 语言中使用宏是可移植的吗?
- python - 在 Python 中从 JSON 文件中提取数据
- python - Seaborn 散点图用循环绘制多个图
- java - 为什么我的 JPanel 没有绘制我的 BufferedImage?