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!
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 !! :)
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.
Sorry for bad english!
Although it is strange this error in localhost, try to make the grant in MySQL:
GRANT ALL PRIVILEGES ON *.* TO 'your_user'@'localhost' IDENTIFIED BY 'your_pass';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.