cool tech graphics

Getting command line access to PHP and MySQL running MAMP on OSX

If you have MAMP installed on your Mac OS X box, you're probably going to want command line access to those applications at some point. Assuming you're running a default install you'll run into difficulty when you type php or mysql without logging into the appropriate directory. In MAMP the directories are as follows:


Rather than referencing those full paths every time you'll probably want to include them in the PATH. You can do this by editing your .profile file. (You can get to the directory where this lives by typing cd).

Use a text editor to open up .profile and change the following line:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

To include the additions to the $PATH like so:

export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php5/bin/:/opt/local/bin:/opt/local/sbin:$PATH

You'll probably need to make the shell reload your profile like so:

. ./.profile

Also if you have any problems connecting to mysql you may need to run the following command:

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

Thanks to the following blog entries:…

Date posted: January 26, 2009


Thnxs :) That helped!

Thanks for the post on CLI access with MAMP. Saved me some time.

Take care,


Thanks this is also work for me and save me a lot of time.

I am unable to find .profile under Snow Leopard. Upon opening Terminal, I have tried the command "open .profile" Telnet replies, "The file /Users/Matthew/.profile does not exist." Any suggestions?

Hmm... I'm not running Snow Leopard, but you should be able to get to your home directory by typing:


Once there try typing:

ls -al

That will give you a list of all of the files in that directory, including files that start with the . character that are otherwise hidden.

To anyone who is having problems getting Zend_Tool working on their MAC OS X (10.6) in Terminal, this is how to solve the problem.

Step 1
Download the Zend Framework to your downloads folder. Once downloaded, rename the folder ZendFramework

Step 2
Open Terminal and type: sudo cp -r ~/Downloads/ZendFramework /usr/local/ZendFrameworkCli

Step 3
In Terminal, type: open ~/.bash_profile

Note: If file is not found...
Open the application TextEdit. Create a new file and make sure you are typing in plain text only. Type the following: alias zf=/usr/local/ZendFrameworkCli/bin/

Save and exit TextEdit

Step 4
In Terminal, type: zf show version


Thought I would update the instructions here for MAMP 1.9

The path has changed to

First, make MAMP's php executable
chmod +x /Applications/MAMP/bin/php5.2/bin/php

then edit your path for the version of PHP you want to use:
export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php5.2/bin/:/opt/local/bin:/opt/local/sbin:$PATH

Thanks, Andrew!

Looks like it may have changed again. I'm running MAMP v2.1.1 and I had to change the PATH to:

export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/\

This was exactly what I was searching for, that symlink saved my - thank you!

thanks to all of the above !!

I changed the password when I was in phpMyAdmin, the root by accident, then I got the following message:
/Applications/MAMP/Library/bin/mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect

How do I fix the root password in the terminal so that I can access the phpMyAdmin again.

hi I am trying to access mysql through the terminal and I keep getting this :Last login: Sat Jul 7 16:17:44 on ttys000
Diane-Friersons-MacBook-Pro:~ dianefrierson$ mysql -u root --password=admin-bash: mysql: command not found
Diane-Friersons-MacBook-Pro:~ dianefrierson$
I know that I'm connected because I use XAMPP and I can access mysql through the admin but I too am following a tutorial and would like to know both ways. please help thanks in advance.. Peace and Blessings

-c /Applications/MAMP/bin/php/php5.4.4/conf/php.ini

(one line)

Just another post by admin. Your posts are really good for user.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <cpp>, <java>, <php>. The supported tag styles are: <foo>, [foo].
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Metal Toad is an Advanced AWS Consulting Partner. Learn more about our AWS Managed Services

About the Author

Joaquin Lippincott, CEO

Joaquin is a 20+ year technology veteran helping to lead businesses in the move to the Cloud. He frequently speaks on panels about the future of tech ranging from IoT and Machine Learning to the latest innovation in the entertainment industry.  He has helped to modernize software for industry leaders like Sony, Daimler, Intel, the Golden Globes, Siemens Wind Power, ABC, NBC, DC Comics, Warner Brothers & the Linux Foundation.

As the CEO and Founder of Metal Toad, an AWS Advanced Consulting Partner, his primary job is to "get the right people in the room".  This one responsibility is cross-functional and includes both external business development functions as well as internal delegation and leadership development.

A UCLA alumni, he also serves in the community as a Board Member for the Los Angeles Area Chamber of Commerce, the Beverly Hills Chamber of Commerce, and Stand for Children Oregon - a public education political advocacy group. As an outspoken advocate for entry-level job creation in tech he helped found the non-profit, P4TH, an organization dedicated to increasing the number of entry-level jobs in the tech industry, and is in the process of organizing an Advisory Board for the Bixel Exchange, a Los Angeles non-profit that provides almost 200 tech internships every year.


Have questions?