在 Laravel 中迁移 table 时出错,但连接数据库没有问题
Error in migration of table in Laravel, though there is no problem in connecting with database
当我尝试使用命令 php artisan migrate --path="2022_04_17_161039_create_cruds_table.php"
迁移 laravel 中的 table 时,出现此错误 -
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = crud and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:745
741▕ // If an exception occurs when attempting to run a query, we'll format the error
742▕ // message to include the bindings with SQL, which will make this exception a
743▕ // lot more helpful to the developer instead of just the database's errors.
744▕ catch (Exception $e) {
➜ 745▕ throw new QueryException(
746▕ $query, $this->prepareBindings($bindings), $e
747▕ );
748▕ }
749▕ }
+33 vendor frames
34 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
但是当我尝试使用 php artisan db mysql
连接数据库时,它工作得很好。
请帮帮我,如果连接数据库没有问题,那么为什么迁移命令不起作用。
此外,我已启用 pdo_mysql
驱动程序。
PHP 需要 php-mysql
扩展才能与 MySQL 通信,如果您之前安装过并且有多个扩展,请确保在您的系统中安装并拥有此扩展PHP 版本,请确保为您需要的 PHP 版本
安装此扩展
当我尝试使用命令 php artisan migrate --path="2022_04_17_161039_create_cruds_table.php"
迁移 laravel 中的 table 时,出现此错误 -
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = crud and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:745
741▕ // If an exception occurs when attempting to run a query, we'll format the error
742▕ // message to include the bindings with SQL, which will make this exception a
743▕ // lot more helpful to the developer instead of just the database's errors.
744▕ catch (Exception $e) {
➜ 745▕ throw new QueryException(
746▕ $query, $this->prepareBindings($bindings), $e
747▕ );
748▕ }
749▕ }
+33 vendor frames
34 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
但是当我尝试使用 php artisan db mysql
连接数据库时,它工作得很好。
请帮帮我,如果连接数据库没有问题,那么为什么迁移命令不起作用。
此外,我已启用 pdo_mysql
驱动程序。
PHP 需要 php-mysql
扩展才能与 MySQL 通信,如果您之前安装过并且有多个扩展,请确保在您的系统中安装并拥有此扩展PHP 版本,请确保为您需要的 PHP 版本