Execute MAMP’s PHP and mysql in command line terminal OSX

Quick tip, if you have MAMP installed on your machine and need to run PHP or mysql via the terminal/command line, you can execute these lines to create symbolic links to point within your MAMP instance:

sudo mv /usr/bin/php /usr/bin/php-bak
sudo ln -s /Applications/MAMP/bin/php/php5.3.14/bin/php /usr/bin/php
sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/bin/mysql

Be sure to change the PHP folder to match the version you want by browsing the following path: /Applications/MAMP/bin/php/

The reason for renaming the existing PHP instance is because OSX runs its own web server (if Web Sharing is enabled).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.