这是我的堆栈跟踪:
Exception 'yii\db\Exception' 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): yii\db\Connection->open() #1 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Connection.PHP(823): yii\db\Connection->getMasterPdo() #2 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Command.PHP(208): yii\db\Connection->getSlavePdo() #3 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Command.PHP(816): yii\db\Command->prepare(true) #4 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Command.PHP(350): yii\db\Command->queryInternal('fetchAll',NULL) #5 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/MysqL/Schema.PHP(198): yii\db\Command->queryAll() #6 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/MysqL/Schema.PHP(97): yii\db\MysqL\Schema->findColumns(Object(yii\db\TableSchema)) #7 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/db/Schema.PHP(140): yii\db\MysqL\Schema->loadTableSchema('migration') #8 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/console/controllers/MigrateController.PHP(121): yii\db\Schema->getTableSchema('{{%migration}}',true) #9 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.PHP(610): yii\console\controllers\MigrateController->getMigrationHistory(NULL) #10 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.PHP(102): yii\console\controllers\BaseMigrateController->getNewMigrations() #11 [internal function]: yii\console\controllers\BaseMigrateController->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): yii\base\InlineAction->runWithParams(Array) #14 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/console/Controller.PHP(91): yii\base\Controller->runAction('',Array) #15 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/base/Module.PHP(455): yii\console\Controller->runAction('',Array) #16 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/console/Application.PHP(161): yii\base\Module->runAction('migrate',Array) #17 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/console/Application.PHP(137): yii\console\Application->runAction('migrate',Array) #18 /opt/lampp/htdocs/advanced/vendor/yiisoft/yii2/base/Application.PHP(375): yii\console\Application->handleRequest(Object(yii\console\Request)) #19 /opt/lampp/htdocs/advanced/yii(31): yii\base\Application->run() #20 {main}
我是yii2的新手.我在advaced / common / config / main-local.PHP中添加了数据库名称,用户名.使用xampp webserver和PHP的版本是5.6.8并且还启用了PDO.
这是我的数据库配置.
'db' => [ 'class' => 'yii\db\Connection','dsn' => 'MysqL:host=localhost;dbname=yii2advanced','username' => 'root','password' => '','charset' => 'utf8',],
在
Yii2发现了这个
“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.”