I am using XAMPP to host local websites I'm developing, and one of those sites is built on Drupal. Recently I ran into an interesting problem: In trying to administer a site with drush I was getting the following error:
seawolf$ drush status PDO::__construct():  No such file or directory (trying to connect [warning] via unix:///var/mysql/mysql.sock) environment.inc:523
I know my database is working, but drush can't see it.
Several people have posted a solution that changes your settings.php file for your Drupal site to point to
127.0.0.1 instead of
localhost, but this didn't work for me (plus, there's a subtle downside to that approach: the connection is slower because of the overhead).
A very simple solution is to just create a link from the file path that drush is looking for to the actual socket created by XAMPP:
seawolf$ sudo ln -s /Applications/XAMPP/xamppfiles/var/mysql /var/mysql seawolf$ drush status PHP executable : /usr/bin/php PHP configuration : PHP OS : Darwin Drush version : 6.0 Drush configuration : Drush alias files :
Note: if you also have a local installation of mysql other than the one in XAMPP, this probably won't work for you (/var/mysql will already exist and can't be both a link and a working directory).