Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database connection "Mysql" is missing and mysql.sock is missing

I was trying to generate model code from cake command line tool. But got this issue.

Warning Error: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in [/Users/test/Google_WWW/project_name/lib/Cake/Model/Datasource/Database/Mysql.php, line 177]

Error: Database connection "Mysql" is missing, or could not be created. (although it's showing that mysql database is connected at localhost in cakephp directory)

I'm using MAMP.

I searched a lot and found some solutions. For instance,this CakePHP: No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)

or I can also make a symbolic link of mysql.sock.

/Applications/MAMP/tmp/mysql/mysql.sock (not present in directory)

But before i do anything, the problem is mysql.sock file isn't present in this directory. I have tried re-installing the MAMP but still no mysql.sock.

Please help me solve this problem ? Can I create my own mysql.sock file..?

Edit: My db config

public $default = array(
    'datasource' => 'Database/Mysql',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'root',
    'password' => 'root',
    'database' => 'db_name',
    'prefix' => ''
);
like image 434
ihaider Avatar asked Oct 11 '13 14:10

ihaider


1 Answers

MAMP is strange when it comes to mysql. Chances are you need to set up a symbolic link so it knows where to find it. Something like:

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

like image 89
Chuck Burgess Avatar answered Sep 24 '22 08:09

Chuck Burgess