Exception #39;could not find driver#39; while migration in yii2(在 yii2 中迁移时出现异常“找不到驱动程序)
问题描述
这是我的堆栈跟踪:
Exception 'yiidbException' with message 'could not find driver'
in /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Connection.php:534
#0 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Connection.php(836): yiidbConnection->open()
#1 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Connection.php(823): yiidbConnection->getMasterPdo()
#2 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Command.php(208): yiidbConnection->getSlavePdo()
#3 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Command.php(816): yiidbCommand->prepare(true)
#4 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Command.php(350): yiidbCommand->queryInternal('fetchAll', NULL)
#5 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/mysql/Schema.php(198): yiidbCommand->queryAll()
#6 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/mysql/Schema.php(97): yiidbmysqlSchema->findColumns(Object(yiidbTableSchema))
#7 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Schema.php(140): yiidbmysqlSchema->loadTableSchema('migration')
#8 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/console/controllers/MigrateController.php(121): yiidbSchema->getTableSchema('{{%migration}}', true)
#9 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(610): yiiconsolecontrollersMigrateController->getMigrationHistory(NULL)
#10 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(102): yiiconsolecontrollersBaseMigrateController->getNewMigrations()
#11 [internal function]: yiiconsolecontrollersBaseMigrateController->actionUp(0)
#12 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
#13 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/base/Controller.php(151): yiiaseInlineAction->runWithParams(Array)
#14 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/console/Controller.php(91): yiiaseController->runAction('', Array)
#15 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/base/Module.php(455): yiiconsoleController->runAction('', Array)
#16 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/console/Application.php(161): yiiaseModule->runAction('migrate', Array)
#17 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/console/Application.php(137): yiiconsoleApplication->runAction('migrate', Array)
#18 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/base/Application.php(375): yiiconsoleApplication->handleRequest(Object(yiiconsoleRequest))
#19 /opt/lampp/htdocs/advanced/yii(31): yiiaseApplication->run()
#20 {main}
我是 yii2 的新手.我在 advaced/common/config/main-local.php
中添加了数据库名称、用户名.使用 xampp 网络服务器,php 版本为 5.6.8,并且还启用了 PDO.
I am new to yii2. I have added database name,username in advaced/common/config/main-local.php
. Using xampp webserver and version of php is 5.6.8 and PDO is also enabled.
这是我的数据库配置.
'db' => [
'class' => 'yiidbConnection',
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
],
推荐答案
在 Yii2
最有可能是你的系统配置.如果你使用的是像这样的包MAMP、XAMPP 或其他,您可能需要将localhost"更改为db.php 配置文件中的127.0.0.1".另外如果你在Linux 你可能需要安装一些其他的附加包,比如php5-mysql 之类的东西."
"Most likely it is your system config. If you are using packages like MAMP, XAMPP or other, you may need to change "localhost" to "127.0.0.1" in your db.php configuration file. Also if you are on Linux you may need to install some other additional packages like php5-mysql and stuff like that."
这篇关于在 yii2 中迁移时出现异常“找不到驱动程序"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 yii2 中迁移时出现异常“找不到驱动程序"
基础教程推荐
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01