I’ve recently been working on a CakePHP project on my Mac, I’ve noticed that when
I tried Baking the project, This error kept popping up :
Warning Error: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in [/Users/xxxxx/Projects/public_html/xxxxxx/lib/Cake/Model/Datasource/Database/Mysql.php, line 157]
After a lookup, seems lots of people seem to come through this when working on MAMP, to fix that, start your terminal and create a link to “mysql.sock” manually
sudo mkdir /var/mysql sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
Now go back and and continueΒ bake π
Thanks a lot!
I was trying to run many php files from the command line and didn’t know the reason why it was showing up some errors when sql statements were run. It took me days until I found out your simple but smart solution. π
I assume that php is looking for a path that would be by default if mysql was installed individually and not as part of MAMP as it was my case. Linking a new folder with the active one used by MAMP is a great idea.
I’m glad it helped, it took me sometime to figure it out π
Pingback: I’ve been having problems hooking CakePHP into MAMP… « « Jay Margalus Jay Margalus
thanks a lot !!!
Thanks a million man!
Thanks Berg! much appreciated.
Pingback: Scheduled Tasks in SilverStripe | Deadly Technology
oh man, thanks mate…. 1 command and you solved 2 days of arguments… π
Thanks a lot
Thanks a lot, first search on facebook, just perfect !
Hello,
Instead of creating a link I think is better to configure the location of the socket in php.ini
Open the php.ini you’re using with MAMP, look for [Pdo_mysql] and right under that you should find a line like this:
pdo_mysql.default_socket=/var/mysql/mysql.sock
Comment out that line (if not commented already) and then add the new location of the mysql.sock
pdo_mysql.default_socket=/Applications/MAMP/tmp/mysql/mysql.sock
Note: If do NOT use MAMP the most likely location on Mac for mysql.sock is /tmp/mysql.sock
I forgot to add that you need to restart you Apache server to pick up the change in php.ini otherwise it won’t work π
I love you so much! I have been searching on how to fix this for a long bloody time!
Much appreciated.
I had problem using Doctrine CLI with Doctrine framework and gave me similar error message. thanks mate that command solved my problem
I had problem using Doctrine CLI with Zend framework and gave me similar error message. thanks mate that command solved my problem
You are a genius, thanks mate!
Thank You very much
Thanks a lot , saved me loads of time π
Watch out … the Apple security update can wipe out the link
Oh thanks a lot for the tip !
Thanks a lot! π
Thanks.
Thanks for this. Got to love the simple fixes.
Thanks!!!
Very usefull!!
WOW that was easy!
Thanks a lot π Helped so much !
Man — I just spent the past three hours of my life trying to find the solution to this problem. Fixed me right uP!
thank you ! π
Thanks mate. Exactly what i was looking for π
Thanks. Nice post …
Legend!!!!!
Very nice, thanks!
Thank you FTW!!!
thanks a lot !!!
Good job
Thanks a lot. You saved my day π
Thanks man!!!
THANK YOU SO MUCH
Thanks a ton! Been struggling with this for hours.
perfect, thank you!
Muitissimo Obrigado!
Resolveu meu problema.
thank you so much !!!
thank you
Darshans-MacBook-Air-2:~ Darshan1$ sudo mkdir /var/mysql
Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
what to type in password ??
mysql.sock not showing in folder π please help
You type your actual account’s password, did you get this to work yet ?
it is 2017 and this just helped me loads!!
lol Thanks it’s strange how this is still relevant, glad to help nonetheless π
The file does not exists for MAMP but if I use the commands it says: File exists. Even if the hidden files are showed the file really does not exists. Do you maybe know how to fix this issue?
look here https://bankhummer.co
cannazon market links – cannazon market onion, cannazon market url