Yii2迁移无法找到数据库

时间:2018-04-12 12:08:50

标签: php migration yii2-advanced-app

我正在尝试从我创建的扩展中迁移两个表。我在XAMPP上创建了它,我的迁移工作正常(测试了几次)。然后我决定在另一台服务器上测试它,我得到的错误是:

Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [1045] Access denied for user 'ivailo'@'localhost' (using password: YES)'

in Z:\extension\slide\vendor\yiisoft\yii2\db\Connection.php:624

Stack trace:
#0 Z:\extension\slide\vendor\yiisoft\yii2\db\Connection.php(996): yii\db\Connection->open()
#1 Z:\extension\slide\vendor\yiisoft\yii2\db\Connection.php(983): yii\db\Connection->getMasterPdo()
#2 Z:\extension\slide\vendor\yiisoft\yii2\db\Command.php(253): yii\db\Connection->getSlavePdo()
#3 Z:\extension\slide\vendor\yiisoft\yii2\db\Command.php(1143): yii\db\Command->prepare(true)
#4 Z:\extension\slide\vendor\yiisoft\yii2\db\Command.php(399): yii\db\Command->queryInternal('fetchAll', NULL)
#5 Z:\extension\slide\vendor\yiisoft\yii2\db\mysql\Schema.php(312): yii\db\Command->queryAll()
#6 Z:\extension\slide\vendor\yiisoft\yii2\db\mysql\Schema.php(125): yii\db\mysql\Schema->findColumns(Object(yii\db\TableSchema))
#7 Z:\extension\slide\vendor\yiisoft\yii2\db\Schema.php(744): yii\db\mysql\Schema->loadTableSchema('migration')
#8 Z:\extension\slide\vendor\yiisoft\yii2\db\Schema.php(194): yii\db\Schema->getTableMetadata('{{%migration}}', 'schema', true)
#9 Z:\extension\slide\vendor\yiisoft\yii2\console\controllers\MigrateController.php(210): yii\db\Schema->getTableSchema('{{%migration}}
', true)
#10 Z:\extension\slide\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(875): yii\console\controllers\MigrateControlle
r->getMigrationHistory(NULL)
#11 Z:\extension\slide\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(166): yii\console\controllers\BaseMigrateContr
oller->getNewMigrations()
#12 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#13 Z:\extension\slide\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array)
#14 Z:\extension\slide\vendor\yiisoft\yii2\base\Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#15 Z:\extension\slide\vendor\yiisoft\yii2\console\Controller.php(148): yii\base\Controller->runAction('up', Array)
#16 Z:\extension\slide\vendor\yiisoft\yii2\base\Module.php(528): yii\console\Controller->runAction('up', Array)
#17 Z:\extension\slide\vendor\yiisoft\yii2\console\Application.php(180): yii\base\Module->runAction('migrate/up', Array)
#18 Z:\extension\slide\vendor\yiisoft\yii2\console\Application.php(147): yii\console\Application->runAction('migrate/up', Array)
#19 Z:\extension\slide\vendor\yiisoft\yii2\base\Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request
))
#20 Z:\extension\slide\yii(23): yii\base\Application->run()
#21 {main}

我的Yii2是全新安装的。仅通过composer添加了扩展名。数据库配置正确(我们使用多年的用户和密码)。我创建了测试表并执行了一行Yii::$app->db->createCommand('INSERT INTO test VALUES (1,'testname')')并且传递正常。这样我决定连接是好的。但是通过控制台迁移php yii migrate/up --migrationPath=@vendor/********/*******/migrations,它给了我上面的错误。想提一下,我不熟悉我们的服务器配置(我所知道的是操作系统:Ubuntu 14.04 H:Apache2),如果问题是以某种方式解决的话,系统管理完全。提前谢谢!

0 个答案:

没有答案