php - 为什么我收到 Laravel php artisan 迁移错误?
问题描述
我是 Laravel 的新手,正在尝试学习在线教程。我到了需要php artisan migrate
在终端中运行的地步,但出现以下错误:
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = some_db and table_name = migrations and table_type = 'BASE TABLE')
at C:\xampp\htdocs\social\vendor\laravel\framework\src\Illuminate\Database\Connection.php:669
665| // If an exception occurs when attempting to run a query, we'll format the error
666| // message to include the bindings with SQL, which will make this exception a
667| // lot more helpful to the developer instead of just the database's errors.
668| catch (Exception $e) {
> 669| throw new QueryException(
670| $query, $this->prepareBindings($bindings), $e
671| );
672| }
673|
1 C:\xampp\htdocs\social\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDOException::("could not find driver")
2 C:\xampp\htdocs\social\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=some_db", "root", "", [])
我已经尝试了在这里可以找到的所有解决方案,并且我已经进入我的php.ini
文件以启用不同的扩展,但似乎没有任何效果。我找到了一个可以尝试运行的解决方案,sudo apt-get install php-mysql
但我使用的是 Windows,所以这不是我的选择。对此事的任何帮助将不胜感激!
解决方案
如果您已经安装了 mysql 驱动程序,则应确保在 .ENV 文件中分配了以下变量// Si ya tienes el controlador para mysql instalado, debes asegurarte que en el archivo .ENV estén las siguientes variables asignadas:
DB_CONNECTION=mysql //mysql driver
DB_HOST=127.0.0.1 //connection host
DB_PORT=3306 //mysql port
DB_DATABASE=laravel //database name
DB_USERNAME=root //database user
DB_PASSWORD= //database password
推荐阅读
- java - Tomcat 7 和 CentOS 7 中的远程调试
- javascript - 使用 ES6 重命名对象的子键
- pyspark - Pyspark - 根据另一个数据帧的行值过滤数据帧
- r - R XML解析为数据框
- python-3.x - 使用 Python 3 按主题名称查找电子邮件
- javascript - 如何将 JavaScript 数组转换为树状结构
- c# - ASP.NET Core ADFS 身份验证未进行身份验证
- scala - SBT 找不到部分统一插件
- android - 在 FirebaseUser.getUid() 上获取 NullPointerException
- azure - 从本地开发中的应用配置访问 Azure Key Vault 参考值