简体   繁体   English

带有消息“找不到驱动程序”的异常“yii\\db\\Exception”

[英]Exception 'yii\db\Exception' with message 'could not find driver'

I have just installed yii2.0 advanced on linux mint 18.2, using XAMPP for Linux 7.0.23, and my php yii migrate/up command doesn't work.我刚刚在 linux mint 18.2 上安装了 yii2.0 advanced,使用 XAMPP for Linux 7.0.23,我的 php yii migrate/up 命令不起作用。 It shows:它显示:

with message 'could not find driver'

in /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/db/Connection.php:584

I had googled it and i got several results.我用谷歌搜索了一下,得到了几个结果。 There, I read 'use php -m command';在那里,我读到“使用 php -m 命令”; you will realize which php have been used by your system.您将意识到您的系统使用了哪些 php。 But I do not know what will be the expected output after running the command.但我不知道运行命令后的预期输出是什么。

 with message 'could not find driver'

in /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/db/Connection.php:584

Stack trace:
#0 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/db/Connection.php(928): yii\db\Connection->open()
#1 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/db/Connection.php(915): yii\db\Connection->getMasterPdo()
#2 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/db/Command.php(219): yii\db\Connection->getSlavePdo()
#3 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/db/Command.php(910): yii\db\Command->prepare(true)
#4 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/db/Command.php(362): yii\db\Command->queryInternal('fetchAll', NULL)
#5 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/db/mysql/Schema.php(199): yii\db\Command->queryAll()
#6 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/db/mysql/Schema.php(98): yii\db\mysql\Schema->findColumns(Object(yii\db\TableSchema))
#7 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/db/Schema.php(152): yii\db\mysql\Schema->loadTableSchema('migration')
#8 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/console/controllers/MigrateController.php(194): yii\db\Schema->getTableSchema('{{%migration}}', true)
#9 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(814): yii\console\controllers\MigrateController->getMigrationHistory(NULL)
#10 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(155): yii\console\controllers\BaseMigrateController->getNewMigrations()
#11 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#12 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#13 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams(Array)
#14 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/console/Controller.php(128): yii\base\Controller->runAction('up', Array)
#15 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/base/Module.php(523): yii\console\Controller->runAction('up', Array)
#16 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate/up', Array)
#17 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('migrate/up', Array)
#18 /opt/lampp/htdocs/yii/vendor/yiisoft/yii2/base/Application.php(380): yii\console\Application->handleRequest(Object(yii\console\Request))
#19 /opt/lampp/htdocs/yii/yii(27): yii\base\Application->run()
#20 {main}

You need install pdo_mysql module.您需要安装pdo_mysql模块。

sudo apt-get install php-mysql

After that check your phpinfo();之后检查你的phpinfo();

I got this error too.我也收到了这个错误。 pdo_mysql driver was installed and shown in phpinfo(), web application run fine, but from command line it could not find driver. pdo_mysql驱动程序已安装并显示在 phpinfo() 中,Web 应用程序运行良好,但从命令行找不到驱动程序。 Solution was to provide php version解决方案是提供php版本

cd /var/www/html/project_folder
php7.1 application/yii.php controller/method

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Yii2 异常 'yii\\db\\Exception' 带有消息“找不到驱动程序” - Yii2 exception 'yii\db\Exception' with message 'could not find driver' 消息“找不到驱动程序”的未捕获异常“ PDOException”(到Oracle DB) - Uncaught exception 'PDOException' with message 'could not find driver' (to an Oracle DB) 未捕获的异常'PDOException',消息'找不到驱动程序' - Uncaught exception 'PDOException' with message 'could not find driver' 消息“找不到驱动程序”的异常“ PDOException” - exception 'PDOException' with message 'could not find driver' 在 yii2 中迁移时出现异常“找不到驱动程序” - Exception 'could not find driver' while migration in yii2 异常'PDOException',消息'找不到驱动程序'SQLSRV Laravel Artisan CLI - exception 'PDOException' with message 'could not find driver' SQLSRV Laravel Artisan CLI 致命错误:未捕获异常“PDOException”,消息“找不到驱动程序” - Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' Symfony 5 异常找不到驱动程序 - Symfony 5 exception Could not find driver Symfony 3 - 驱动程序中发生异常:找不到驱动程序 - Symfony 3 - An exception occurred in driver: could not find driver Symfony:驱动程序发生异常:找不到驱动程序 - Symfony : An exception occurred in driver: could not find driver
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM