Working on trackstar app, chapter 8 RBAC problem


I’m reading the yii book and I’m stuck in the chapter 8.

I’m getting an error when I try to run a rbac script.

this is the error.

>> rbac

exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in /Users/adrian/Sites/yiiRoot/framework/db/CDbConnection.php:382

Stack trace:

#0 /Users/adrian/Sites/yiiRoot/framework/db/CDbConnection.php(331): CDbConnection->open()

#1 /Users/adrian/Sites/yiiRoot/framework/db/CDbConnection.php(309): CDbConnection->setActive(true)

#2 /Users/adrian/Sites/yiiRoot/framework/base/CModule.php(388): CDbConnection->init()

#3 /Users/adrian/Sites/yiiRoot/framework/web/auth/CDbAuthManager.php(586): CModule->getComponent('db')

#4 /Users/adrian/Sites/yiiRoot/framework/web/auth/CDbAuthManager.php(60): CDbAuthManager->getDbConnection()

#5 /Users/adrian/Sites/yiiRoot/framework/base/CModule.php(388): CDbAuthManager->init()

#6 /Users/adrian/Sites/yiiRoot/framework/base/CModule.php(104): CModule->getComponent('authManager')

#7 /Users/adrian/Sites/trackstar/protected/commands/shell/RbacCommand.php(21): CModule->__get('authManager')

#8 /Users/adrian/Sites/yiiRoot/framework/cli/commands/ShellCommand.php(130): RbacCommand->run(Array)

#9 /Users/adrian/Sites/yiiRoot/framework/cli/commands/ShellCommand.php(101): ShellCommand->runShell()

#10 /Users/adrian/Sites/yiiRoot/framework/console/CConsoleCommandRunner.php(65): ShellCommand->run(Array)

#11 /Users/adrian/Sites/yiiRoot/framework/console/CConsoleApplication.php(91): CConsoleCommandRunner->run(Array)

#12 /Users/adrian/Sites/yiiRoot/framework/base/CApplication.php(162): CConsoleApplication->processRequest()

#13 /Users/adrian/Sites/yiiRoot/framework/yiic.php(33): CApplication->run()

#14 /Users/adrian/Sites/trackstar/protected/yiic.php(7): require_once('/Users/adrian/S...')

#15 /Users/adrian/Sites/trackstar/protected/yiic(4): require_once('/Users/adrian/S...')

#16 {main}

I’m using Yii 1.10 version. I use MAMP as well.

This is my code on config/main.php config/console.php


			'class' => 'CDbConnection',

			'connectionString' => 'mysql:host=;dbname=trackstar_dev;',

			'emulatePrepare' => true,

			'username' => 'root',

			'password' => 'root',

			'charset' => 'utf8',






I read some post but I got the same error.

I tried:

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock

Change localhost to

please any help.




‘connectionString’ => ‘mysql:host=;dbname=trackstar_dev;’,

replace with

‘connectionString’ => ‘mysql:host=;dbname=trackstar_dev’,

Try now


Hi, thanks.

But I did the change and I got the same error.

Any other suggested???


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

so check if you have PDO_mysql PHP module installed. You can check this using phpinfo() command.

yes. I just checked and I have that extension.

PDO support enabled

PDO drivers sqlite, sqlite2, pgsql, mysql.

Is it a yii error or it’s about configuration???

Did you check phpinfo() through web? or also through CLI (commandline)? you may have different php.ini for those environments and disabled PDO_mysql in CLI…

If I use this, it works.

php -c /Applications/MAMP/bin/php/php5.3.6/conf/php.ini ./yiic shell config/main.php

Do you know the way to configure the php.ini. I want this /Applications/MAMP/bin/php/php5.3.6/conf/php.ini as default.

thanks for your help.

I found that the database configuration for the console needs to have


after running

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock

while the database configuration for the main does not need a socket specified.