Getting Drush working with MAMP 3 on Mac

If you are like me and new to Drush here are the steps I followed to get it working with MAMP 3 on my Mac running 10.9 Mavericks. The main problem I had was Drush not being able to connect to my Drupal database. After an entire day of troubleshooting this is what ended up working for me.

  1. Download and install a fresh copy of Drush on Github. A great tutorial of how to do that can be found here. You will need to install Composer as well.
  2. After Drush is installed and you can see the commands by running drush from the terminal, create a bash_profile file if you don’t already have one. sudo nano ~/.bash_profile
  3. If you have a PHP 5.4 or higher installed, put this into your bash_profile file.  export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.4/bin:$PATH"
  4. Save the file.
  5. Reload bash_profile by running source ~/.bash_profile
  6. If you get a PDO error when performing a Drush command, then try running these. sudo mkdir /var/mysql and
    sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock


UPDATE (3/24/2015) – It seems as MAMP now has its PHP versions installed in /MAMP/bin/php/php{whatever the version is} Step 3 will have to be modified to reflect that. For instance, instead of export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.4/bin:$PATH" it will be export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.5.18/bin:$PATH"