Yii2 db mysql connection throw ssh port 33060

10,379

Solution 1

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 !! :)

Solution 2

I suspect your main issues would be that you have not specified the port:

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

I assume that you meant to put 33060 as opposed to 3306.

Share:
10,379
Admin
Author by

Admin

Updated on June 11, 2022

Comments

  • Admin
    Admin almost 2 years

    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!