M
M
Michael2019-06-23 00:16:45
MySQL
Michael, 2019-06-23 00:16:45

Why does the database migration fail?

Hello everybody! Please explain why the error shown below occurs when migrating a database to a project:

In the process of restoring the dump occurred error: SQLSTATE[HY000] [1045] Access denied for user 'shop'@'localhost' (using password: YES)

The name of the database and the user of the database is fedorov_shop, and in the error it displays the user name shop
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=fedorov_shop',
'username' => 'fedorov_shop',
'password' => '***',
'charset' => 'utf8',
'enableSchemaCache' => true,
'schemaCacheDuration' => 3600,

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
ThunderCat, 2019-06-23
@ThunderCat

Access denied for user 'shop '@'localhost'

configs? Search by string in a project?
PS: a couple of months ago, something similar slipped, like different configs for different environments were connected somewhere.

D
Dmitry, 2019-06-23
@slo_nik

Good morning.
Which template are you using, advanced or base?
Are there any other configs?
During migration, you can explicitly specify which database to migrate to.
In the config file

'db' => [
   'class' => 'yii\db\Connection',
   'dsn' => 'mysql:host=localhost;dbname=fedorov_shop',
   'username' => 'fedorov_shop',
   'password' => '***',
   'charset' => 'utf8',
   'enableSchemaCache' => true,
   'schemaCacheDuration' => 3600,
]

On the command line.
You can also specify in the migration itself which database to work with.
public function init()
    {
        $this->db = 'db2';
        parent::init();
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question