Cannot generate mysql models using Yiic shell

Hi everyone, I know it says I’m a newb, but that’s just to this forum. I’m having trouble using the Yii framework in conjunction with a local MySQL server, no matter what I do, I cannot seem to get it to connect through the shell and generate models for what I need.

 as per most unix installations, my webroot folder is '/var/www/html', 

here’s the exception I get however when I’m trying to run the shell utility

exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in /var/www/html/yii/framework/db/CDbConnection.php:267

Stack trace:

#0 /var/www/html/yii/framework/db/CDbConnection.php(242): CDbConnection->open()

#1 /var/www/html/yii/framework/db/CDbConnection.php(221): CDbConnection->setActive(true)

#2 /var/www/html/yii/framework/base/CModule.php(363): CDbConnection->init()

#3 /var/www/html/yii/framework/base/CApplication.php(391): CModule->getComponent('db')

#4 /var/www/html/yii/framework/cli/commands/shell/ModelCommand.php(260): CApplication->getDb()

#5 /var/www/html/yii/framework/cli/commands/ShellCommand.php(144): ModelCommand->run(Array)

#6 /var/www/html/yii/framework/cli/commands/ShellCommand.php(99): ShellCommand->runShell()

#7 /var/www/html/yii/framework/console/CConsoleCommandRunner.php(62): ShellCommand->run(Array)

#8 /var/www/html/yii/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)

#9 /var/www/html/yii/framework/base/CApplication.php(135): CConsoleApplication->processRequest()

#10 /var/www/html/yii/framework/yiic.php(33): CApplication->run()

#11 /var/www/html/messy/protected/yiic.php(7): require_once('/var/www/html/y...')

#12 /var/www/html/messy/protected/yiic(4): require_once('/var/www/html/m...')

#13 {main}

I did however run phpInfo() using a dummy file in my webroot


MySQL Support	enabled

Active Persistent Links 	0

Active Links 	0

Client API version 	5.1.46


MYSQL_SOCKET 	/var/lib/mysql/mysql.sock

MYSQL_INCLUDE 	-I/usr/include/mysql

MYSQL_LIBS 	-L/usr/lib/mysql -lmysqlclient 

here’s my main.php fie (specifically the section on connecting to a MySQL server)


			'connectionString' => 'mysql:host=localhost;dbname=mydb;unix_socket=/var/lib/mysql/mysql.sock',

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => '*******',


I’ve tried so many variations of this however, none of them seem to work.

not to mention, If I put the following lines in a dummy index.php file, they DO connect to my database.

$connection= new CDbConnection('mysql:host=localhost;dbname=mydb', 'root', '*********');


I’m really at a loss here, any help is truly appreciated

also, here are a couple snippets from my php.ini file, they seem to be in order

; Default port number for mysql_connect().  If unset, mysql_connect() will use

; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the

; compile-time value defined MYSQL_PORT (in that order).  Win32 will only look



mysql.default_port =

; Default socket name for local MySQL connects.  If empty, uses the built-in

; MySQL defaults.


mysql.default_socket = /var/lib/mysql/mysql.sock

; Default host for mysql_connect() (doesn't apply in safe mode).


mysql.default_host = localhost



You did check the right php.ini file, did you? PHP servermodule and CLI use different ini files. See the redish box here:

You can enter this command, to find the right ini file:

php --ini