Just trying to do basic stuff with the Yii 1.1 shell:
>> model User tbl_user
Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in /htdocs/yii/framework/db/CDbConnection.php on line 297
exception ‘CDbException’ with message ‘CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2002] No such file or directory’ in /htdocs/yii/framework/db/CDbConnection.php:262
Stack trace:
#0 /htdocs/yii/framework/db/CDbConnection.php(237): CDbConnection->open()
#1 /htdocs/yii/framework/db/CDbConnection.php(216): CDbConnection->setActive(true)
#2 /htdocs/yii/framework/base/CModule.php(357): CDbConnection->init()
#3 /htdocs/yii/framework/base/CApplication.php(391): CModule->getComponent(‘db’)
#4 /htdocs/yii/framework/cli/commands/shell/ModelCommand.php(260): CApplication->getDb()
#5 /htdocs/yii/framework/cli/commands/ShellCommand.php(144): ModelCommand->run(Array)
#6 /htdocs/yii/framework/cli/commands/ShellCommand.php(99): ShellCommand->runShell()
#7 /htdocs/yii/framework/console/CConsoleCommandRunner.php(62): ShellCommand->run(Array)
#8 /htdocs/yii/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)
#9 /htdocs/yii/framework/base/CApplication.php(135): CConsoleApplication->processRequest()
#10 /htdocs/yii/framework/yiic.php(31): CApplication->run()
#11 /htdocs/yii/pitch/protected/yiic.php(7): require_once(’/Applications/M…’)
#12 /htdocs/yii/pitch/protected/yiic(4): require_once(’/Applications/M…’)
#13 {main}
>>
My connection string for mysql is configured in protected/config/main.php:
‘db’=>array(
'connectionString' => 'mysql:host=localhost;dbname=yiidb1',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
),
The database exists and has a tabled named tbl_user in it.
Why doesn’t this work?