【发布时间】:2021-12-04 06:04:53
【问题描述】:
我正在尝试按照本教程 https://www.youtube.com/watch?v=074AQVmvvdg&list=PL4cUxeGkcC9hL6aCFKyagrT1RCfVN4w2Q&index=13 进行迁移
我认为本教程可能已过时,因为当我输入 php artisan migrate; 时出现此错误:
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = pizzahouse and table_name = migrations and table_type = 'BASE TABLE')
at C:\Users\jonke\Documents\laravel\pizzahouse\vendor\laravel\framework\src\Illuminate\Database\Connection.php:703
699▕ // If an exception occurs when attempting to
run a query, we'll format the error
700▕ // message to include the bindings with SQL,
which will make this exception a
701▕ // lot more helpful to the developer instead
of just the database's errors.
702▕ catch (Exception $e) {
➜ 703▕ throw new QueryException(
704▕ $query, $this->prepareBindings($bindings), $e
705▕ );
706▕ }
707▕ }
1 C:\Users\jonke\Documents\laravel\pizzahouse\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDOException::("could not find driver")
2 C:\Users\jonke\Documents\laravel\pizzahouse\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDO::__construct()
我已阅读视频中的 cmets,在那里我找到了解决早期错误的方法。我在此页面上尝试了以下建议:https://github.com/laravel/framework/issues/24711,这看起来很有希望,但并不快乐。
我在这个网站上发现了描述相同错误消息但原因不同的页面。一个看起来很有希望,但 vscode 不喜欢 sudo apt-get 位。 (我丢失了链接,抱歉)。
这个标题相似但不好用:Migration in Laravel 5.6 - could not find driver
我也尝试过关注官方文档:https://laravel.com/docs/8.x/migrations
如何在 vscode 的命令行中创建数据库但不运行迁移?我不明白!这几天一直在转圈子,有人能帮帮我吗?
谢谢
【问题讨论】:
-
错误是说你没有安装 pdo_mysql 扩展(如果这是关于 mysql)
-
是关于MySQL的,听从你的建议,我一直在寻找如何安装pdo_mysql但找不到,请问你有什么建议吗?
-
在 Windows 上,您通常可以取消注释
php.ini中的相关行。在某些 linux 发行版中,您可以执行apt-get install php-pdo-mysql
标签: php laravel visual-studio-code migration