I have had a cakephp app running fine on my local machine (mac osx) for a while and then suddently I realise that I can\'t connect to mysql.sock.
I\'m getting this
If you are having problem with CakePHP 2.0, try this:
sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
Try passing an absolute path the the mysql.sock file in the APP/config/database.php
<?php
class DATABASE_CONFIG {
var $default = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'dbUser',
'password' => 'dbPassword',
'database' => 'dbName',
'prefix' => '',
'port' => '/path/to/mysql.sock'
);
}
This is better than running via an ip for local connection as the socket connection is much, much faster.
In phpcake 2.0 use 'unix_socket' instead of port
<?php
class DATABASE_CONFIG {
var $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'dbUser',
'password' => 'dbPassword',
'database' => 'dbName',
'prefix' => '',
'unix_socket' => '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock', //Path for mac XAMPP
);
}