Since a couple of days now, i switched from a ubuntu machine to a macbook pro retina for my development works.

I installed XAMPP on it, without to much trouble. But I have been struggeling with drush for quite some time now, and I am hoping to find a little help here.

Drush partially works... I can download Drupal, download modules etc. I CANNOT enable the modules, perform sql-cli commands (however sql-connect DOES work?!).

The error i get is:

Command pm-enable needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command.                                           [error]
The drush command 'en token' could not be executed.                                                                                                                                              [error]
Drush was not able to start (bootstrap) the Drupal database.                                                                                                                                     [error]
Hint: This may occur when Drush is trying to:
 * bootstrap a site that has not been installed or does not have a configured database. In this case you can select another site with a working database setup by specifying the URI to use with
the --uri parameter on the command line. See `drush topic docs-aliases` for details.
 * connect the database through a socket. The socket file may be wrong or the php-cli may have no access to it in a jailed shell. See http://drupal.org/node/1428638 for details.

Drush was attempting to connect to: 
 Drupal version         :  7.28                                                                          
 Site URI               :  http:// default                                                                
 Database driver        :  mysql                                                                         
 Database hostname      :  localhost                                                                     
 Database username      :  root                                                                          
 Database name          :  drupal_site                                                                      
 PHP executable         :  /usr/bin/php                                                                  
 PHP configuration      :  /Users/myusername/drush/php.ini /Users/myusername/drush/php.ini 
 PHP OS                 :  Darwin                                                                        
 Drush version          :  7.0-dev                                                                       
 Drush temp directory   :  /tmp                                                                          
 Drush configuration    :                                                                                
 Drush alias files      :                                                                                
 Drupal root            :  /Applications/XAMPP/htdocs/drupal_site                                           
 Site path              :  sites/default      

Now I have been googling around for this for days and found numerous topics, stating all kinds of things (change your settings.php file to use instead of localhost => did not work)

One thing i would like to add is that i discovered that my OS runs a different php version as the XAMPP instance?!

Ps: My drupal_site is fully functional! Just drush won't work with me.

Any help would be very much appreciated!


4 Answers 4


Your drush is using system php, whereas Drupal is using XAMPP's. This reliably creates drush problems.

Look into XAMPP and figure out where its php binary is and then set your path accordingly in .bashrc or whatever other shell init files you have sitting around.

Check your progress with drush status, in particular what it reports for the database connection.


You can explicitly provide drupal installation using --root option

drush status --root=/path/to/drupal

OR you can create a alias for your site,

First find where is your drush home directory is,

drush ev 'print(drush_server_home());'

Now create a file,

vim drush_home_path/.drush/drushrc.php  

and put the contents as below,

$aliases['drupal_site'] = array(
  'root' => '/path/to/drupal/',
  'uri' => 'drupal_site',
  • Dear shrish, thanks for your reply. Unfortunatly this did not work :(. I am running xampp under /Applications/XAMPP/xamppfiles/htdocs/my_site. My drush root is under /Users/my_username/drush. There i created the folder .drush (since it was not there) and created a drushrc.php file there with $aliases['my_site'] = array( 'root' => '/Applications/XAMPP/xamppfiles/htdocs/my_site', 'uri' => 'my_site.dev', ); and the result is the same :-(. I don't understand that it is this difficult? In ubuntu i just installed it vear pear and it was done. No aliasses no nothing... Thanks once again!!
    – Guardian
    Commented Jul 15, 2014 at 20:49

@ChristophWeber got me on the right track. I solved the problem by opening my .bash_profile (create your own if you don't already have one). I then added these two lines. The first tells drush to use the XAMPPs PHP rather than the default. The second line makes mySQL available (you can test if mysql is available by typing 'mysql' into the terminal).

Lines to add to .bash_profile:

export DRUSH_PHP='/Applications/XAMPP/bin/php'
export PATH=/Applications/XAMPP/bin/:$PATH
  • FYI, if ChristophWeber's answer helped you, you should select it as the correct answer and then add your details to it in a comment.
    – Christia
    Commented Oct 20, 2017 at 17:40

Use "" instead of "localhost" as the hostname.

  • Author already mentioned that he did this.
    – mpdonadio
    Commented Jul 16, 2014 at 22:38
  • Bump... Any more suggestions?
    – Guardian
    Commented Aug 13, 2014 at 6:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.