NewUser
NewUser

Reputation: 13333

CDbConnection error in Yii

Whenever I am trying to login in my Yii application it is showing error like

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

I googled many hours and from many blogs I knew that I need pdo_mysql but that is already installed. In php.ini I also made comment these lines

;extension=php_pdo_mysql.dll

;extension=php_mysql.dll

and restarted apache server but still showing the same prob. I am using ubuntu 11.04. Please help me to solve the error.

Upvotes: 5

Views: 6506

Answers (5)

rapttor
rapttor

Reputation: 499

First make sure you have

sudo apt install php-xml php-mbstring php-pdo php-mysql 

installed, and restart apache

sudo service apache2 restart

My solution was related to caching:

cache' => array(
    'class' => 'system.caching.CDbCache',
    //'class' => 'system.caching.CFileCache',
    'connectionID'=>'db', // <<< THIS IS THE ISSUE
),

if connectionID is not set, db caching defaults to mysqli database in /protected/data directory which cannot be accessed if mysqli driver is not installed on system (common issue with dedicated servers, DO droplets, xampp/wamp...) or, you can disable db caching and enable fileCache instead.

Upvotes: 0

Ranjeet Singh
Ranjeet Singh

Reputation: 702

Install

sudo apt-get install php5-sqlite 

and restart the apache2

sudo service apache2 restart

its work for me.

Upvotes: 0

Fo Nko
Fo Nko

Reputation: 634

i dont understand why you have the first line commented, you should UNCOMMENT

extension=php_pdo_mysql.dll

it worked for me!

Upvotes: 0

udog
udog

Reputation: 1536

sudo apt-get install php5-mysql followed by sudo apache2ctl graceful worked for me on Ubuntu Desktop

Upvotes: 6

shikhar
shikhar

Reputation: 2469

For Ubuntu(linux), you will need to recompile Apache. Simple uncommenting will not work. In Ubuntu, I believe you can do some apt-get.

Upvotes: 0

Related Questions