CakePHP on OSX: Problem using Bake.php script


If you are getting the following errors while trying to bake something on osx 10.4:
"Warning: mysql_connect(): Can't connect to local MySQL server through
socket ‘/var/mysql/mysql.sock’ (2) in
/Library/WebServer/Documents/development/bakery/cake/libs/model/dbo/dbo_mysql.php
on line 117″

try doing the following:
sudo ln -s /tmp /var/mysql

Or you could follow the instruction given by Apple: Mac OS X Server 10.4: Issues connecting PHP to MySQL

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts
CakePHP: Central cake core install with multiple apps
Top 5 red flags of software development

Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Tried that, but it didn’t remove the issue for me :(
I’m using 1.2.0.5146alpha version with MAMP. CakePHP is able to connect to the database otherwise.

I have edited the /etc/my.cnf file as follows:

[mysqld]
socket=/Applications/MAMP/tmp/mysql/mysql.sock

That solved the baking issues with the stable version of cake. Can’t figure out what the problem is with 1.2. though…

Hi Junior Baker,

Thanks for giving the fix for others that use the MAMP install….
The fix I provided was only for the stand-alone MySQL installations.

I had the same problem. Thanks for the post!

A temporary dirty fix for MAMP and the latest SVN build:

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

Hi.

Another (better) solution (assuming you are in scripts directory of a Cake):

* for php5
$ ../../../../bin/php5/bin/php bake.php

* for php4
../../../../bin/php4/bin/php bake.php

Works perfectly.

Hi all,

the problem is that cake uses php as command interpreter, therefore if you call “php” from the console you will use the default /bin/php
Because I have MAMP, the solution was to set the path to use the php interpreter provided:
you just have to “reverse” the path order:
export PATH=/Applications/MAMP/bin/php5/bin:$PATH

Thanks thomas :)

Thanks TM!!

If yopu are using xampp rather than mamp (or the Apple webserver), the only required change is

export PATH=/Applications/xampp/xamppfiles/bin:$PATH

If you place that line in your .profile, you will always call php scripts (like cake) using the xampp php installation instead of the Apple one.