// you’re reading...

OSX

CakePHP on OSX: Problem using Bake.php script

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

Discussion

Comments are disallowed for this post.

  1. 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…

    Posted by Junior baker | July 3, 2007, 10:45 am
  2. 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.

    Posted by max | July 4, 2007, 8:55 pm
  3. I had the same problem. Thanks for the post!

    Posted by Brian Pan | September 8, 2007, 11:35 pm
  4. A temporary dirty fix for MAMP and the latest SVN build:

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

    Posted by tm | September 28, 2007, 12:39 am
  5. 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.

    Posted by Tomasz Zwierzchon | September 30, 2007, 2:34 pm
  6. 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

    Posted by thomas | May 10, 2008, 7:14 pm
  7. Thanks thomas :)

    Posted by milkshake | June 5, 2008, 5:14 pm
  8. Thanks TM!!

    Posted by Pablo | June 10, 2008, 6:08 am
  9. 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.

    Posted by tim | September 1, 2008, 4:39 am