CDbConnection failed to open the DB connection: could not find driver in Yii

user2853731 picture user2853731 · Dec 5, 2013 · Viewed 46.2k times · Source

while trying to connect with mysql in yii framework it shows

"CDbConnection failed to open the DB connection: could not find driver " error

php code :

     'db'=>array(
        'class' => 'CDbConnection',
        'connectionString' => 'mysql:host=localhost:3306;dbname=testdrive',
        'emulatePrepare' => true,
        'username' => 'root',
        'password' => 'root',
        'charset' => 'utf8',
    ), 

my php drivers are already enabled , but it shows the same error

Im using zend studio, zend server for this

how could i fix this?

Answer

ackuser picture ackuser · Aug 20, 2014

I am using Linux Mint..In my case I needed

apt-get install php5-mysql 

because I was moving my environment from Lampp to Apache + PHP + MySQL and I had to change a lot of things in the php.ini