Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2 db mysql connection throw ssh port 33060

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!

like image 427
Este Avatar asked Jul 09 '15 12:07

Este


2 Answers

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

like image 145
Este Avatar answered Nov 07 '22 18:11

Este


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.

like image 33
The Humble Rat Avatar answered Nov 07 '22 18:11

The Humble Rat