Problem with MySQL

Hi,

i tried to finish the "creating your first yii application" from the PDF guide that comes with the installation, but i wanted to use MySQL since i do not have SQLite.

So i added the following to my config file:


		'db'=>array(

			'class'=>'CDbConnection', 

			'connectionString'=>'mysql:host=localhost;dbname=yiitest',

			'username'=>'****', 

			'password'=>'****'

		),

Then i followed the steps, starting the shell and typed "model User" to create the Model, and the following error appeared and i have no idea how to solve the problem.


Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in /Users/as/Sites/yii/framework/db/CDbConnection.php on line 290

exception 'CDbException' with message 'CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2002] No such file or directory' in /Users/as/Sites/yii/framework/db/CDbConnection.php:255

Stack trace:

#0 /Users/as/Sites/yii/framework/db/CDbConnection.php(230): CDbConnection->open()

#1 /Users/as/Sites/yii/framework/db/CDbConnection.php(209): CDbConnection->setActive(true)

#2 /Users/as/Sites/yii/framework/base/CModule.php(353): CDbConnection->init()

#3 /Users/as/Sites/yii/framework/base/CApplication.php(373): CModule->getComponent('db')

#4 /Users/as/Sites/yii/framework/cli/commands/shell/ModelCommand.php(246): CApplication->getDb()

#5 /Users/as/Sites/yii/framework/cli/commands/ShellCommand.php(144): ModelCommand->run(Array)

#6 /Users/as/Sites/yii/framework/cli/commands/ShellCommand.php(99): ShellCommand->runShell()

#7 /Users/as/Sites/yii/framework/console/CConsoleCommandRunner.php(62): ShellCommand->run(Array)

#8 /Users/as/Sites/yii/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)

#9 /Users/as/Sites/yii/framework/base/CApplication.php(135): CConsoleApplication->processRequest()

#10 /Users/as/Sites/yii/framework/yiic.php(31): CApplication->run()

#11 /Users/as/Sites/yiitest/protected/yiic.php(7): require_once('/Users/as/Sites...')

#12 /Users/as/Sites/yiitest/protected/yiic(4): require_once('/Users/as/Sites...')

#13 {main}



I am running yii on MAMP for OSX SnowLeopard.

Hello,

you have to define the path of the unix socket. See here.

okay, it now works with:


'db'=>array(

	'class'=>'CDbConnection', 

	'connectionString'=>'mysql:host=127.0.0.1;port=8889;dbname=****',

	'username'=>'***', 

	'password'=>'***' 

		),

But note that connecting thru tcp is slower. So in production environment you should enter the correct unix socket path in php.ini and then connect with mysql:host=localhost

the installation was really simple.

just uncomment the mysql row and replace with your own database information and you are ready to go!

As the posts above state, it did not work and the solution was to add the port number as described.

Thanks for the Advise! I will do that.