php - 在 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 文件中的扩展名,但没有任何改变!
解决方案
你在 Linux 上吗?php-mysql
如果是的话,如果您在 Ubuntu 上,则必须安装该软件包;如果您php-mysqlnd
在 Fedora 上,则必须安装该软件包。
在 Windows 和 macOS 上,所有这些东西都内置在 WAMP 或 MAMP 或任何使用的东西中。
推荐阅读
- php - 选择的 Laravel 刀片选项不起作用
- c# - 类型中的每个属性名称必须是唯一的
- node.js - 如何使用带有 cors 原点和角度的会话?
- sql - 将列转换为特定单词的行
- shell - 从 URL 列表中获取页面标题
- laravel - 如何使用编辑数据表的列
- java - 以编程方式在垂直 LinearLayout 中添加约束布局?
- haskell - 从 Coq 提取 Prop 到 Haskell 会导致空类型
- arrays - 函数中的 PostgreSQL 数组格式化
- c# - 我有多个表,我想在 2 个表中存储包含数据的文件,如何使用 AngularJs 在不同的表中上传不同的文件?