CDbConnection failed to open the DB connection Yii

Wenn ich versuche eine Verbindung zu mysql mit klarem PHP, seine Arbeitsmethoden in Ordnung.
Mein code

$link = mysql_connect('hostname', 'username', 'password'); 
if (!$link) { 
      die('Could not connect'); 
} 
if(mysql_select_db('dbname')){
      echo 'Connected successfully'; 
}

Aber wenn ich versuche zu verbinden mit yii, dann immer die Fehler

Meine 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',
),

Dies ist die Ausgabe für die Ausnahme, was ich drucken in open () - Funktion framework/db/CDbConnection.php
Ausnahme behandeln hier

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);
            }
        }
    }
}

Ausnahmetext

"SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client"

Sehe ich im display

 CDbException

CDbConnection failed to open the DB connection.

Meine PHP-VERSION 5.5.36 Mysql version 5.5.35
Mein Hosting i-Seite dot com
Yii Version 1.1.13'
Danke für die Hilfe.

Nur die überprüfung, sondern ist der 'db' - array innerhalb der 'Komponenten' array in Ihrem main/config.php? Können Sie auch einfügen, wie Sie mit der open-Funktion der CDbConnection?
Ihr problem im Zusammenhang mit der pdo-rufen Sie Ihre hosting zu installieren oder überprüfen Sie diesen link stackoverflow.com/questions/13375061/...

InformationsquelleAutor styopdev | 2014-04-02

Schreibe einen Kommentar