首页 > 解决方案 > 连接被拒绝 SQL: select * from information_schema.tables where table_schema = firstdb and table_name = migrations and table_type = 'BASE TABLE

问题描述

我已经安装并打开了 XAMPP,这就是我访问 phpmyadmin 页面的方式。我在 phpmyadmin 中创建了一个名为“firstdb”的数据库。

我还在本地存储的 laravel 文件中创建了身份验证。我正在尝试使用 php artisan migrate 迁移表,但出现以下错误。

user@Andress-MacBook-Pro admin-panel % php artisan migrate

   Illuminate\Database\QueryException 

  SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = firstdb 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| 

      +37 vendor frames 
  38  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

我到处找,请帮忙。

标签: phplaraveldatabase-migrationmigrate

解决方案


它可能是您.env文件中的错误 mysql 端口号。检查您的.env文件并确保端口号与 mysql 正在使用的端口号匹配。


推荐阅读