When i try connect to mysql with clear PHP, its working fine.
My code
$link = mysql_connect('hostname', 'username', 'password');
if (!$link) {
die('Could not connect');
}
if(mysql_select_db('dbname')){
echo 'Connected successfully';
}
But when im trying to connect with yii, then getting the error
My config/main.php
'db'=>array(
'class'=>'CDbConnection',
'connectionString' => 'mysql:host=hostname;dbname=dbname',
'emulatePrepare' => true, /* I try false too*/
'username' => 'username',
'password' => 'password',
'charset' => 'utf8',
),
This is output for exception what i print in open() function framework/db/CDbConnection.php
Exception handle here
protected function open()
{
if($this->_pdo===null)
{
if(empty($this->connectionString))
throw new CDbException('CDbConnection.connectionString cannot be empty.');
try
{
Yii::trace('Opening DB connection','system.db.CDbConnection');
$this->_pdo=$this->createPdoInstance();
$this->initConnection($this->_pdo);
$this->_active=true;
}
catch(PDOException $e)
{
echo '<pre>';
var_dump($e); die;
if(YII_DEBUG)
{
throw new CDbException('CDbConnection failed to open the DB connection: '.
$e->getMessage(),(int)$e->getCode(),$e->errorInfo);
}
else
{
Yii::log($e->getMessage(),CLogger::LEVEL_ERROR,'exception.CDbException');
throw new CDbException('CDbConnection failed to open the DB connection.',(int)$e->getCode(),$e->errorInfo);
}
}
}
}
Exception text
"SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client"
I see in display
CDbException
CDbConnection failed to open the DB connection.
My PHP VERSION 5.5.36 Mysql version 5.5.35
My Hosting is i-page dot com
Yii Version ‘1.1.13’
Thanks for help.