首页 > 解决方案 > 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()

我在这里和其他网站搜索我的问题,但找不到确切的解决方案。希望能得到一个

标签: laravel

解决方案


检查您的文件 .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 中删除缓存文件并运行应用程序


推荐阅读