Hi everyone,
I’m trying to use yiic shell and yiic migrate tools on my iMac but I seem to be running in to some difficulties. I think it may be because I am using AMPPS as my development server instead of having installed Apache/PHP/MySQL separately. For example, I can invoke the yiic shell but when I run:
echo Yii::app()->db->connectionString;
I get this lengthy error message:
Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Applications/AMPPS/YiiRoot/framework/db/CDbConnection.php on line 423
exception 'CDbException' with message 'CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2002] No such file or directory' in /Applications/AMPPS/YiiRoot/framework/db/CDbConnection.php:381
Stack trace:
#0 /Applications/AMPPS/YiiRoot/framework/db/CDbConnection.php(330): CDbConnection->open()
#1 /Applications/AMPPS/YiiRoot/framework/db/CDbConnection.php(308): CDbConnection->setActive(true)
#2 /Applications/AMPPS/YiiRoot/framework/base/CModule.php(387): CDbConnection->init()
#3 /Applications/AMPPS/YiiRoot/framework/base/CModule.php(103): CModule->getComponent('db')
#4 /Applications/AMPPS/YiiRoot/framework/cli/commands/ShellCommand.php(131) : eval()'d code(1): CModule->__get('db')
#5 /Applications/AMPPS/YiiRoot/framework/cli/commands/ShellCommand.php(131): eval()
#6 /Applications/AMPPS/YiiRoot/framework/cli/commands/ShellCommand.php(99): ShellCommand->runShell()
#7 /Applications/AMPPS/YiiRoot/framework/console/CConsoleCommandRunner.php(67): ShellCommand->run(Array)
#8 /Applications/AMPPS/YiiRoot/framework/console/CConsoleApplication.php(91): CConsoleCommandRunner->run(Array)
#9 /Applications/AMPPS/YiiRoot/framework/base/CApplication.php(169): CConsoleApplication->processRequest()
#10 /Applications/AMPPS/YiiRoot/framework/yiic.php(33): CApplication->run()
#11 /Applications/AMPPS/www/TrackStar/protected/yiic.php(7): require_once('/Applications/A...')
#12 /Applications/AMPPS/www/TrackStar/protected/yiic(4): require_once('/Applications/A...')
#13 {main}
I think it is perhaps because it is trying to connect via
unix:///var/mysql/mysql.sock
which isn’t where my MySQL shell resides. I have configured my config/main.php and config/console.php to reflect:
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=trackstar',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'mysql',
'charset' => 'utf8',
),
Can anyone help? I have the same problem when I try to use the migrations feature.