PDO::__construct(): [2002] No such file or directory – Drush Problem

February 17th, 2011 admin Location: Raleigh, NC, Topic: Web Design | Digital Media

So let’s say that you decided to install drush in your Mac OS and also you were running MAMP at the time and everything was working great a while ago. But lets say that you decided to upgrade Drush. And you simply grabbed the latest version of Drush from the repository in Drupal.org and everything worked great.

Now, for any crazy reason, let’s say that you decided to install a testing environment of Drupal 7 just for the kicks. And when you do just that you would probably find out that you can’t install Drupal 7 without having enough lift power on your php. It has to be PHP 5.2 at least. That would mean that you have MAMP 1.6 installed in your MAC and therefore you need to upgrade that as well. The process of upgrading the MAMP should be pretty straightforward.

1. Backup your entire MAMP directory in your Applications folder. What I did was to rename it MAMP_bkp and that’s that.

2. I downloaded the new MAMP tarball and then extracted and installed in my Applications folder.

3. I then copied the databases from my backup to my new MAMP folder and that’s it.

4. In case you changed the location of your root directory, then you need to change this also in your MAMP preferences. Where? Go to MAMP > Preferences > APACHE> Document Root  and change it to your old localhost.

Ok so far so good. Now the problem would be if you wanted to simply go back and use Drush. The reason is that now drush is going to give you a nasty error that says something along the lines of:

PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) [warning]
in drush_valid_db_credentials() (line 952 of

So what do you do to fix it and go back to having fun?


The first solution would be to troubleshoot the problem for hours, then go online and try to find an answer and then try to implement all of the ones people talk about and find that some work.

Or you can just type the following:
First, determine where is your php running from in your MAMP. You may do so by creating a simple php file in your root directory and inside the php file type the following:

Now, visit the page and it should show you all your php configurations for your web server. Search for the path.

Now with the path of your php in hand, simply fire up Terminal and type the following command (updated thanks to Phil), make sure that you replace the /Applications/MAMP/bin/php5.3/bin/php part with your own path to php:

AC:d7 youruser$ sudo ln -f /Applications/MAMP/bin/php5.3/bin/php /usr/bin/php

A nice little link.

Now go to a nice restaurant and enjoy a nice meal for 2 hours and then come back to work. You deserve it.

About the Author

Alex Centeno MBA., is an international creative director and digital media strategist. Currently residing minutes away from the Research Triangle Park (RTP) - North Carolina, and with over 10 years of interactive marketing training and experience, Alex leads Merkados' international clients to maximizing their online business strategies. One of Alex's biggest strengths is his world-class capacity to effectively combine interactive marketing, digital media design and web development.

You may find further information about Alex Centeno MBA. at: and Twitter.

Sobre el Autor

Alex Centeno MBA., Es un director creativo y estratega de medios digitales reconocido internacionalmente. En la actualidad reside a tan solo minutos del Research Triangle Park (RTP) - Carolina del Norte, y con más de 10 años de entrenamiento y experiencia en marketing interactivo, Alex lidera a los clientes internacionales de Merkados™ para maximizar sus estrategias de negocios en línea. Una de las mayores fortalezas de Alex es su capacidad global de combinar de manera efectiva, mercadeo interactivo, diseño de medios digitales y desarrollo web.

Para más información sobre Alex Centeno MBA. puede visitar: y Twitter.