just a heads up… if you’re trying to use cakephp on os x with a mysql database, you’ll probably have problems connecting to the database server (by default).in my case, i created the mysql database (using the mysql command-line client), created a mysql user for the application (and gave it the appropriate permissions), configured cakephp’s database.php configuration file, and tried to access the default page. i was presented with the following error:
Warning: mysql_connect() [function.mysql-connect]: Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’ (2) in /Library/WebServer/Documents/application_name/cake/libs/model/dbo/dbo_mysql.php on line 100
the fix for this is pretty easy. i’ve seen recommendations to just make a symbolic link from /var/mysql/mysql.sock to /tmp/mysql.sock, but that’s not really a good idea. instead, open up /etc/php.ini in your text editor (as root), find the line that begins with “mysql.default_socket = ” and change the entire line so that it reads “mysql.default_socket = /tmp/mysql.sock” (make sure there’s not a semicolon at the beginning of the line). save the file, exit, and restart apache (“apachectl restart”) and you should be good to go.Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /Library/WebServer/Documents/application_name/cake/libs/model/dbo/dbo_mysql.php on line 105
note that if you don’t have an /etc/php.ini file, but you do have /etc/php.ini.default, simply copy the default file over (e.g. “cp /etc/php.ini.default /etc/php.ini”), then do the fix above.
related posts:






4 comments ↓
Thanks a lot for the help!
Just what I needed!
excellent, glad i be of some help!
hey!!! perfect! works ok!
sos un capo!
my thanks… from argentina
Thanks a lot :)
Leave a Comment