首页 > 解决方案 > 在 laravel 7 应用程序中找不到驱动程序

问题描述

我正在尝试将数据库与我的 Laravel 7 应用程序连接,但每次点击时都会php artisan migrate 出现以下错误。

我已经连接了我的 .env 文件,如下所示:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=""

照亮\数据库\查询异常

  could not find driver (SQL: select * from information_schema.tables where table_schema = test 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| 

      +32 vendor frames 
  33  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

我尝试了几种方法,包括取消注释 php.ini 文件中的扩展名,但没有任何改变!

标签: phpmysqllaravellaravel-7

解决方案


你在 Linux 上吗?php-mysql如果是的话,如果您在 Ubuntu 上,则必须安装该软件包;如果您php-mysqlnd在 Fedora 上,则必须安装该软件包。

在 Windows 和 macOS 上,所有这些东西都内置在 WAMP 或 MAMP 或任何使用的东西中。


推荐阅读