I used this tutorial to get MAMP up and running.

The next mission is getting drush to work on this setup.

1. Downloaded latest version of Drush to my Desktop and unzipped.

2. Dragged the unzipped directory to /usr/bin/drush

3. Chmoded /usr/bin/drush/drush to become executable as instructed in README.txt.

4. Created the following alias to drush in spencerHD/Users/spencer/.profile):

alias drush='/usr/bin/drush/drush'

5. Logged out and logged back in.

6. Navigated to my Drupal 6.14 site at Applications/MAMP/htdocs/localttc and tried "drush status" but no luck. -bash: drush: command not found

I'm curious to know if I did something wrong or need to look at another angle to get this running. It looks like a great module so if you have any suggestions or tips I'd be grateful.

Thank you very much.


pobster’s picture

Drush shouldn't need an alias if you've put it in /usr/bin - you need to read the installation instructions a bit more carefully!

Try typing this though - DON'T log out afterwards;

source /spencerHD/Users/spencer/.profile

Then try the drush command...


markabur’s picture

what works for me is this (in .bash_profile, not in .profile):

alias drush='/Applications/MAMP/bin/php5/bin/php /usr/bin/drush/drush.php'
export COLUMNS

you have to tell drush to use the MAMP version of php as the system one is different.

spangaroo’s picture

Excellent, that did the trick. Thanks a lot for your help markabur! :)

marthinal’s picture

Works for me.Thanks.

The only source of knowledge is experience. ~ Albert Einstein.

s4j4n’s picture

I had big problems with a OS_X_10.6 + MAMP_1.9 + drush setup, but I solved the issues so I thought I'd post it here in case anyone else was bumping into similar issues. Though if anyone has ideas why some of these problems were popping up - sharing that info would be much appreciated.

If you are using MAMP and want to use drush, install drush as directed in the README but use the php located in /Applications/MAMP/bin/php5.2/bin

  • back up your site files and database
  • chage your .bash_profile alias for drush to use MAMP's php:
    alias drush='/Applications/MAMP/bin/php5.2/bin/php /path/to/drush/drush.php'
    export COLUMNS
  • allow MAMP's php to be executable by drush chmod +x /Applications/MAMP/bin/php5.2/bin/php
    otherwise you will receive permission errors such as...
    $ drush
    -bash: /Applications/MAMP/bin/php5.2/bin/php: Permission denied
  • you probably will want to increase the max memory allowed for any php script in memory_limit from 32M to 96M or 128M or greater here: /Applications/MAMP/conf/php5.2/php.ini
  • restart your MAMP servers
  • open a new terminal

Note that you can also use the php located in /Applications/MAMP/bin/php5.3/bin but I got a bunch of warnings/errors with drush when I did that due to various modules I was using that aren't 5.3 compatible (or haven't been upgraded to versions that are 5.3 compatible). Likewise MAMP can be set to use php 5.2 or 5.3 - with similar results regarding warnings/errors that will pop up inside drupal admin pages.

Regarding my experience with using Mac's default PHP...

I recently upgraded to Snow Leopard (10.6) and also upgraded my MAMP to 1.9 (released: 2010-04-16). At each stage I tested my local sites and they were working fine.

Reinstalled drush and the first round of warnings/errors began. I was just using the default Mac provided php and received various warnings...

$ drush dl backup_migrate
PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock)     [warning]
SQLSTATE[HY000] [2002] No such file or directory                                                        [warning]
Project backup_migrate (6.x-2.2) downloaded to                                                          [success]

and sometimes errors...

$ drush en backup_migrate
PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) environment.inc:955    [warning]
SQLSTATE[HY000] [2002] No such file or directory                                                                           [warning]
Drush was not able to start (bootstrap) the Drupal database.                                                               [error]
Hint: This error often occurs when Drush is trying to bootstrap a site that has not been installed or does not have a
configured database.

Drush was attempting to connect to : 
  Drupal version    : 6.15
  Site URI          : http://default
  Database driver   : mysqli
  Database hostname : localhost
  Database username : example
  Database name     : example
  Default theme     : garland
  Administration theme: garland
  PHP configuration : 
  Drush version     : All-versions-3.0
  Drush configuration: 
  Drupal root       : /Users/lclusr/wwwroot/example
  Site path         : sites/default
  Modules path      : sites/all/modules
  Themes path       : sites/all/themes
  %paths            : Array

You can select another site with a working database setup by specifying the URI to use with the --uri parameter on the
command line or $options['uri'] in your drushrc.php file.

Command pm-enable needs a higher bootstrap level to run - you will need invoke drush from a more functional Drupal         [error]
environment to run this command.
The drush command 'en backup_migrate' could not be executed.                                                               [error]

Just for the record the site was already installed and had a working configured database.

Also I've installed a mysql server on my mac via fink previously, but I am not using it and it is not running. Still - not sure if some of these Mac default php problems I was experiencing are due to some settings my mysql installation created somewhere or something that's the usual experience for people using 10.6.

After all this I opted to try to use the php supplied in MAMP and after some trial and error arrived at the steps shown in the list above.

s4j4n’s picture

my approach listed above worked fine (just changing your .bash_profile) for a while, but today I tried to update my modules and core, but ran into a similar set of errors when drush tried to updatedb.

see this node for another approach using hard links and further discussion.

entrigan’s picture

How do you tell mamp to use php 5.2?

pobster’s picture

There's an option to chose 5.3.x or 5.2.x in the server menus, it's in the documentation;

1.3.7 PHP
PHP Version: Choose whether PHP 5.2.x or PHP 5.3.x should be used. The exact
PHP version depends on the installed MAMP version. For more information, please
consult the MAMP version history.

...Come on, you really could have Googled that?... That's just pure laziness!


entrigan’s picture

On the Mamp control panel go preferences -> PHP and there is an option for 5.2 or 5.3

iainH’s picture

php executable is in a new location with this version of MAMP (PRO).

So in your ~/.bash_profile or ~/.bash_exports the correct PATH export for drush to work is:

export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.2.17/bin:$PATH"

or .../php5.3.6/bin as appropriate to your set up.

batigolix’s picture

confirm that the symbolic link as explained in http://drupal.org/node/726970#comment-2914148 works for mamp 2.0.3 and osx 10.7.1:

sudo ln -f /Applications/MAMP/bin/php/php5.3.6/bin/php /usr/bin/php

xmacinfo’s picture

@batigolix: Thanks. I also confirm the symbolic link fix for MAMP 2.0.5 and Lion 1.7.2.


thejtate’s picture

Had a few issues with the same errors when trying to run 'drush cc' or 'drush core-cron' with a migrated Drupal site onto my local machine.

Worked for me:
export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.4.10/bin:$PATH"

Thanks @batigolix

garethhallnz’s picture

I have had a lot for problems in the past to get drush to play nice with MAMP.

Here is my guide and it seem to work fine.

Note MAMP should be running

1. Download drush from http://drupal.org/project/drush
2. Move the downloaded file to the desktop
3. Decompress the downloaded file
4. Open terminal
5. Create a new folder for drush
Terminal command: sudo mkdir /usr/local
6. Move the drush to new folder
Terminal command: sudo mv ~/Desktop/drush /usr/local
7. Make drush folder writable so self update will work
Terminal command: sudo chmod 0777 /usr/local/drush/
8. Make drush executable
Terminal command: sudo chmod u+x /usr/local/drush/drush
9. Create symbolic link so MAMP php is the default php
Terminal command:
sudo ln -fs /Applications/MAMP/bin/php/php5.3.6/bin/php /usr/bin/php
10. Create symbolic link so MAMP mysql is default mysql
We need 2
Terminal command:
sudo ln -fs /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
sudo mkdir /var/mysql
sudo ln -fs /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql/mysql.sock
11. Create a .profile file. So you can execute drush from anywhere
Terminal command: sudo nano.profile
Then copy and past the below from start to end
alias drush='/Applications/MAMP/bin/php/php5.3.6/bin/php /usr/local/drush/drush.php'

export PHP_VERSION="5.3.6"

# HOME folders
export MAMP_HOME="/Applications/MAMP"

export DRUSH_PHP="$PHP_HOME/bin/php"

export PATH="$MAMP_HOME/bin:$PATH"
export PATH="$MAMP_HOME/Library/bin:$PATH"
export PATH="$PHP_HOME/bin:$PATH"

12. Then save the .profile file
Press: Control + x
Press: y
Press: return

13. Quit terminal to reload .profile file

14. Drush should now be working
Terminal command: drush
This should return a bunch drush related commands
Terminal command: mysql
This should give the a mysql prompt

Code should read like well written English

videographics’s picture

Problem with last terminal command in step 10:

sudo ln -fs /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql/mysql.sock

'/tmp/mysql/mysql.sock' No such file or directory.

paul2’s picture

I suspect the line in step 10 is supposed to be this:

sudo ln -fs /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

videographics’s picture

sudo nano.profile

should have a space after 'nano' so it reads

sudo nano .profile

It's minor but it's likely to trip up some noobs.

busla’s picture

I followed the steps but neither "drush" or "mysql" is working. I restarted the whole system but still nothing.

kmccarthy’s picture

I'm just installing drush locally and this saved me a lot of work so thanks for that!

As mentioned drush was accessing Mac OSX' native php in /private/etc/php and seemed to get lost with the native MySQL instance as well. Some tweaks:

Step 9:
Note that php executable in MAMP has moved within the current version (2.0.5) one level deeper so now default path is: /Applications/MAMP/bin/php/phpversion/bin/php
In my case I added the extra task to rename the native php executable to php.original prior to setting the soft link to MAMP's php.
mv /usr/bin/php /usr/bin/php.original
I also did took the same steps with php-config - renamed the native and linked to the one in MAMP.

Step 10:
Rather than link only to the mysql.sock in MAMP I linked to the entire directory as the .pid is also included now:
sudo ln -s /Applications/MAMP/tmp/mysql /var/mysql

Step 11;
As I am using bash I already had a .bash_profile so I copied the lines you indicated (with the tweaks as just mentioned) into that rather than creating the .profile.
After clearing drush's cache, it now seems to be running fine and using the mysql and php instances that the local sites use.

Thanks again for the clean documentation!

xmacinfo’s picture

Drush as now a new very efficient way to install Drush that is compatible with MAMP.

pear channel-discover pear.drush.org
pear install drush/drush

Once installed like this, upgrading through pear is quick and easy.

alexanansi’s picture

This worked for me, so much easier than trying to do it manually


jasonslade’s picture

After beating my head against the wall, I found this did the trick:

sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

No more errors, and Drush works as expected within the local site install.

mrded’s picture

Sorry guys, but you cannot use /usr/bin/ folder for drush. Because this folder for system bins only.
For custom bins we must use folder like /usr/local/bin/

But unfortunately OSX don't use this folder by default =)
For fix it we can add "PATH=$PATH:/usr/local/bin" to ~/.bash_profile

cat "PATH=$PATH:/usr/local/bin" >> ~/.bash_profile
source ~/.bash_profile

But drush is not just bin, it's folder with files.
Because of this we need to copy it to /opt/ folder and create symlink to /usr/local/bin

So, this is more "Linux way":

sudo git clone https://github.com/msonnabaum/drush.git /opt/drush
sudo chown -R www /opt/drush
ln -s /opt/drush/drush /usr/local/bin/drush
Kristina Katalinic’s picture

Hi mrded,
looks to me like you know your way around Mac :) I am a recent convert from PC so I don't :P anyways.... I hope you can help me setup drush properly
I Installed it using

pear channel-discover pear.drush.org
pear install drush/drush

command and it seems to be working but i can't really use it because its not connecting to my MAMP Pro php and I have no idea how to access .bash_profile to make changes....

Where is my .bash_profile now and how do I access it to make changes?

Thanks in advance

Brisbane Web Design, Development and SEO consulting services.

Kristina Katalinic’s picture

but and added following line to it export PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.3.14/bin:$PATH and I also did sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock/code> but I am still getting Command field-info needs a higher bootstrap level to run - you will [error]
need to invoke drush from a more functional Drupal environment to run
this command.
The drush command 'field-info' 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
* 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.

help anyone?

btw I am running on Mountain Lion

Brisbane Web Design, Development and SEO consulting services.

jphelan’s picture

Same issue on Lion, anyone figure it out?

Also when I run
sudo ln -fs /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

I get
ln: /tmp/mysql/mysql.sock: No such file or directory

jasonslade’s picture

You need to create the folder first, on Lion.

So, the steps are:

sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
jkwilson’s picture

Be sure you've also got port 8889 (if you're using MAMP default) specified in your database area of settings.php (hat tip).