V
V
Vitaly Zvonkov2019-01-24 15:05:47
Yii
Vitaly Zvonkov, 2019-01-24 15:05:47

Why can't run the migration (php yii migrate)?

I'm using a LAMP server built by Vagrant and configured with PuPHPeT.
This is what I get after running the command (php yii migrate) :

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

in /var/www/project/vendor/yiisoft/yii2/db/Connection.php:624

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

main-local.php :
<?php
return [
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=127.0.0.1;dbname=yii2advanced',
'username' => 'yii2user',
'password' => '111111',
'charset' => 'utf8',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
],

Tried changing 127.0.0.1 to localhost doesn't help (don't even know if that should have helped)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2019-01-24
@Discreight

Access denied for user 'yii2user'@'localhost' (using password: YES)'

The base listens and hears you. And she doesn't like the way you introduce yourself.
Check if there is such a user, if he has exactly such a password.

S
Sergey S., 2019-01-24
@seganim

Wrong username and password. Base name, its existence also check.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question