Yii2 db mysql connection throw ssh port 33060

Este picture Este · Jul 9, 2015 · Viewed 8.9k times · Source

I have problem with connecting to mysql database throw ssh on port 33060, My conf :

return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=myDatabase',
'emulatePrepare' =>true,
'username' => 'user',
'password' => 'password',
'charset' => 'utf8',
];

I have open ssh tunel when I try to connect, and i have an error:

SQLSTATE[28000] [1045] Access denied for user 'user'@'localhost' (using password: YES)

What am I doing wrong? Is possible in Yii2 to connect throws ssh?

Thanks for answers!

Answer

Este picture Este · Jul 9, 2015

I was solve this problem... :

return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=127.0.0.1;port=33060;dbname=myDatabase',
'emulatePrepare' =>true,
'username' => 'user',
'password' => 'password',
'charset' => 'utf8',
 ];

It must be 127.0.0.1 not localhost. Thanks for all answers !! :)