Using drush and XAMPP together on OSX

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(): [2002] 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).

Category: 

Comments

Thank you so much for this information.  This really did help me out!!  A huge Thank you!
Howdy just wanted to give you a quick heads up. The text in your post seem to be running off the screen in Firefox. I'm not sure if this is a formatting issue or something to do with browser compatibility but I thought I'd post to let you know. The design look great though! Hope you get the issue solved soon. Kudos
I truly love your website.. Excellent colors & theme. Did you build this website yourself? Please reply back as I'm planning to create my own website and want to learn where you got this from or exactly what the theme is named. Thank you!
Hi, this weekend is fastidious in favor of me, because this moment i am reading this enormous educational piece of writing here at my home.

Add new comment