S
S
Sergey2015-03-06 23:55:13
Yii
Sergey, 2015-03-06 23:55:13

Why can't I connect to db in yii2?

in config/db.php I write:

return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=name',
    'username' => 'user',
    'password' => 'pass',
    'charset' => 'utf8',
    'tablePrefix' => 'sel_',
];

name, database, user and password are correct.
The user has full privileges on the database (I add them via Cpanel from the hoster)
I even tried to create new ones - the same garbage.
There are more projects on the hosting, I looked at their configs.
Localhost is specified, the port is null there - i.e. ports are standard and access from localhost should be no problem.
phpinfo() pdo found. Those. the problem is not that.
But yii2 throws an error:
2d0487e3196243db95ccb2d9881473bf.png
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zooks, 2015-03-07
@butteff

Access denied means that there is no access to the database for this user.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question