How To Use MySQL On MAMP Via Terminal

I’m still quite new to the use of command line, so if there is any better way of doing this, please don’t hesitate to let me know in the comments.

To connect to your MAMP MySQL database via command line, first navigate to the correct directory within your MAMP installation using the Terminal (or another SSH client). Example:

 cd /applications/mamp/Library/bin

Then run the command to connect to MySQL (the default user and password are both ‘root’).

 mysql -u root -p

You should now see this:


Here is a very nice post with some more details:
And a list of terminal commands and their meaning:

To avoid typing the location of MySQL each time you open the terminal, you can set the location by default. Open the ‘bash_profile’ file in the user root:

 pico .bash_profile

Add the location of MySQL in a new line:

 export PATH=$PATH:/Applications/MAMP/Library/bin/mysql

Instructions on how to use the Pico editor here:

Now you should get to MySQL simply by typing mysql into the terminal.

4 thoughts on “How To Use MySQL On MAMP Via Terminal

  • You forgot dot before “bash_profile”.
    It should be “pico .bash_profile”.

    And thnx btw

  • And anyway your avoiding method did’t work for me.

    I’ve found another if anyone is interested:
    sudo ln -s /Applications/MAMP/Library/bin/mysql /usr/local/bin/mysql

    And that’s it. 🙂

Leave a Reply

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


Angebot anfordern

Ich melde mich innerhalb von 24 Stunden zurück.